Disable multiple hours of datetimepicker downloader
2 answers
This should work:
$(".datepicker").datetimepicker({
hoursDisabled: '0,1,2,3,4,5,6,7,18,19,20,21,22,23'
});
and also this:
hoursDisabled: [0, 1, 2, 3, 4, 5, 6, 7, 8, 18, 19, 20, 21, 22, 23]
Because in bootstrap-datetimepicker.js:
setHoursDisabled: function (hoursDisabled) {
this.hoursDisabled = hoursDisabled || [];
if (!$.isArray(this.hoursDisabled)) {
this.hoursDisabled = this.hoursDisabled.split(/,\s*/);
}
...
},
+3
source to share
In the file, bootstrap-datetimepicker.js
disabled hours are defined as follows:
var hoursDisabled = this.hoursDisabled || [];
If you only use date and time in one place, you can simply change that []
to [0, 1, 2, 3, 4, 5, 6, 7, 8, 18, 19, 20, 21, 22, 23]
in your original javascript file. But if you are using date and time in multiple places, it is better to change the disabled clock in your html file or in a separate js file. Here's the code for that:
<script type="text/javascript">
$('.form_datetime').datetimepicker('setHoursDisabled', [0, 1, 2, 3, 4, 5, 6, 7, 8, 18, 19, 20, 21, 22, 23]);
</script>
0
source to share