I am using this Module But How Can I Disable Future and Current Dates...
_handleDatePicked = (date) => {
var DateFormat = moment(date).format("YYYY-MM-DD");
console.log('A date has been picked:'+DateFormat);
var d1 =new Date();
d1.setHours(0,0,0,0)
var d = new Date(DateFormat);
d.setHours(0,0,0,0)
var n = d.getDate();
var m = d1.getDate();
if(m < n){
Alert.alert("Hello", 'Current Date and Future Dates Not allowing')
console.log("n:"+n +":"+"m:"+m)
}
else{
this.setState({
DateOfBirth:DateFormat
})
}
this._hideDateTimePicker();
};
This Code Is Not Allowing Future Dates But Allowing CurrentDate , I want Disable Current Date Also
Hey @lavarajallu, sorry for answering so late. Are you still having the issue?
I'm on vacation right now, I'll take a look at it when I'll be back.
how can you resolve this issue?
To block future dates initialize your DateTimePicker with maximumDate prop likes so:
<DateTimePicker
isVisible={this.state.isDateTimePickerVisible}
maximumDate={new Date()}
onConfirm={this.handleDatePicked}
onCancel={this.hideDateTimePicker}
/>
To block current date use maximumDate like so:
<DateTimePicker
isVisible={this.state.isDateTimePickerVisible}
onConfirm={this.handleDatePicked}
maximumDate={new Date(Date.now() - 86400000)}
onCancel={this.hideDateTimePicker}
/>
Most helpful comment
To block future dates initialize your DateTimePicker with maximumDate prop likes so:
To block current date use maximumDate like so: