Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disable some hours bootstrap datetimepicker

I want to disable selecting some hours with bootstrap datetimepicker because I want to select only time from 8:00 am to 19:00 pm.

I can't find nothing about that. Can you help me?

like image 692
maures Avatar asked Feb 10 '23 05:02

maures


1 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*/);
        }
        ...
    },
like image 183
Konservin Avatar answered Feb 14 '23 00:02

Konservin