Set a list of available times in jquery timepicker

109 Views Asked by At

I am trying to set a list of predefined times in a jQuery timepicker. It should run from 10am to 12 midnight. I am also trying to highlight certain times that there is no availability. I believe my code is mostly correct for this functionality. What I really need help with is getting the timepicker to show only the selected times.

var times = ["6:00 PM", "5:00 PM"];
    $('#timepicker').timepicker
        ({
            timeFormat: 'h:mm p',
            interval: 60,
            minTime: '10:00am',
            maxTime: '12:00am',
            startTime: '10:00',
            dynamic: false,
            dropdown: true,
            scrollbar: true,
            beforeShowDay: function (time) {
                var string = jQuery.timepicker.formatTime('h:mm p', time);
                if ($.inArray(string, times) != -1) {
                    return [true, 'highlighted-time'];
                } else {
                    return [true, ''];
                }
            },
        });

I have found this:

disableTimeRanges: [['3:00am', '4:30am'], ['5:00pm', '8:00pm']],

However it does not seem to be working in deployment.

0

There are 0 best solutions below