Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

bootstrap 3 datetimepicker jquery

i'm using Datetimepicker from https://eonasdan.github.io/bootstrap-datetimepicker/ for my project.

enter image description here

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.

like image 591
pat3ck029 Avatar asked Oct 31 '22 17:10

pat3ck029


1 Answers

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.

like image 127
meskobalazs Avatar answered Nov 11 '22 20:11

meskobalazs