0
rated 0 times
[
6]
[
6]
/ answers: 1 / hits: 8098
/ 5 Years ago, fri, august 23, 2019, 12:00:00
For example: today is August 23 at 4 pm.
I make to disabled dates until 22 (I used minDate = {moment ().toDate ()}
). How to make disabled time in this case up to 16 (include)? That you cannot choose a date and time earlier than at the present.
I use the react-datepicker
and moment
libraries.
Code here: https://stackblitz.com/edit/react-msygf9
class App extends Component {
constructor() {
super();
this.state = {
selected: new Date()
};
}
handle = (date) => {
this.setState({
selectedDate: date
})
}
render() {
return (
<div>
<DatePicker
selected={this.state.selected}
onChange={this.handle}
showTimeSelect
timeFormat=HH:mm
timeIntervals={15}
dateFormat=MMMM d, yyyy h:mm aa
timeCaption=time
minDate={moment().toDate()}
/>
</div>
);
}
}
More From » reactjs