Disable past time for today like an hour, minutes, sec etc using ant design. is there any simple solution than 'disabledHours' like minTime etc.
<TimePicker format="h:mm:ss A" disabledHours={() => [1, 2, 3]} />
In the Flutter date range picker, you can enable or disable the past dates by using the enablePastDates property of the calendar. When setting the enablePastDates property value as false, you can't able to select the past dates.
In the Data type Format dialog box, do one of the following: To format the control to show the date only, select the display style that you want in the Display the date like this list. To format the control to show the time only, select the display style that you want in the Display the time like this list.
Interval Time Picker. This package modifies the default Flutter Time Picker widget by adding interval options when picking minutes. This means you can restrict the user from picking only certain intervals of minutes and you can choose to which interval of minutes the Time Picker will snap to in dial mode.
You should try to set the disableHours and disabledMinutes of your TimePicker:
<TimePicker
disabledHours={this.getDisabledHours()}
disabledMinutes={this.getDisabledMinutes()}
>
...
getDisabledHours = () => {
var hours = [];
for(var i =0; i < moment().hour(); i++){
hours.push(i);
}
return hours;
}
getDisabledMinutes = (selectedHour) => {
var minutes= [];
if (selectedHour === moment().hour()){
for(var i =0; i < moment().minute(); i++){
minutes.push(i);
}
}
return minutes;
}
And if you want to disable seconds you do the same thing with the disabledSeconds
function which has a signature of function(selectedHour, selectedMinute)
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With