Search code examples
javascriptjquerydatetimepickerbootstrap-datetimepicker

Enable specific dates using bootstrap-datetimepicker


It is possible to enable specific dates using bootstrap-datetimepicker.min.js? I have tried:

$('.date').datetimepicker({
    language: "en-gb",
    enabledDates: ["2020-11-20, 2020-11-22, 2020-11-25"],
    pickTime: false
});

but just only first date 2020-11-20 is enabled. I have an array of specific dates which I need to enable. Other days must be disabled.

I have stuck here. Maybe it is impossible?


Solution

  • enabledDates take an array of string, Date object or moment object.

    Takes an [ string or Date or moment ] of values and allows the user to select only from those days.

    From documentation

    So you were close... Just take care about the array structure!

    Try this:

    $('.date').datetimepicker({
        language: "en-gb",
        enabledDates: ["2020-11-20", "2020-11-22", "2020-11-25"], // Check the quotes!
        pickTime: false
    });