Reputation: 273
i'm using Datetimepicker from https://eonasdan.github.io/bootstrap-datetimepicker/ for my project.
what i want to achieve is that the end should not be able to pick time earlier than the start.
$('#timePickerStart').datetimepicker({
format : 'LT'
});
$('#timePickerEnd').datetimepicker({
format : 'LT'
});
the datetimepicker has a function like that for date, but i don't know how to implement it in time.
thanks.
Upvotes: 5
Views: 439
Reputation: 16041
You can disable certain time intervals with the disabledTimeIntervals
property and function. It takes two moment
objects in an array. The other way is disabling certain hours with the disabledHours
property and disabledHours()
function.
What you could do is this: when the user changes one of the pickers, run a callback. In this callback, you can use the date()
function, to get the current moment, then set it for the other picker as an upper/lower bound with disabledTimeIntervals
.
Upvotes: 2