I'm using bootstrap timepicker and I need it to show time only between 10 AM and 10 PM. I've checked through the options and there seems to be no option for this. Is there any other way that I've missed for doing this?
Asked
Active
Viewed 4,990 times
1
-
You can extend plugin by setting options while initializing timepicker and required customization in js – Nitin Dhomse Jul 28 '16 at 05:04
-
Yeah but there is no option for this. – Shekhar R Jul 28 '16 at 05:24
-
have you tried hourMin:10 and hourMax:22 ? – Nitin Dhomse Jul 28 '16 at 05:43
-
no that didn't work – Shekhar R Jul 28 '16 at 06:19
2 Answers
1
I've found a way to set start time and end time for bootstrap timepicker finally. Adding the below code will get it working. In my code, its showing from 10 AM to 10 PM.
$('#timepicker').timepicker().on('changeTime.timepicker', function (e) {
var hour = e.time.hours;
if (e.time.meridian === "PM" && hour !== 12) {
hour += 12;
}
hour += (e.time.minutes / 100);
if (hour < 10) {
$('#timepicker').timepicker('setTime', '10:' + e.time.minutes + ' AM');
}
else if (hour > 22) {
$('#timepicker').timepicker('setTime', '10:' + e.time.minutes + ' AM');
}
});

Shekhar R
- 81
- 1
- 2
- 8
0
you can passe an array disabledTimeIntervals to your datepicker. For exemple :
$('#mydatepicker').datetimepicker( {
disabledTimeIntervans :
[
[moment().hour(0), moment().hour(10).minutes(00)],
[moment().hour(0), moment().hour(22).minutes(00)]
]
});

lchabrand
- 165
- 9
-
This one is for datetimepicker. What I need is bootstrap timepicker. – Shekhar R Jul 28 '16 at 05:14