我正在禁用时间输出。请看一下随附的图片。我已经导入setHours
和setMinutes
库
state = {
startTime: new Date(),
time: null
};
handleChange = time => {
this.setState({
startTime: time,
});
};
render() {
return (
<div className="dateandtime-picker-box">
<DatePicker
autoFocus={false}
placeholderText="Time"
className="react-datepicker-wrapper"
selected={this.state.startTime}
onChange={time => this.handleChange(time)}
maxTime={setHours(setMinutes(new Date(), 30), 17)}
minTime={setHours(setMinutes(new Date(), 30), 7)}
isClearable
showTimeSelect
showTimeSelectOnly
timeIntervals={30}
timeCaption="Time"
dateFormat="h:mm aa"
>
</DatePicker>
</div>
)
}