Search code examples
javascriptbootstrap-datetimepicker

Bootstrap datetimepicker datesDisabled


I use bootstrap datetimepicker and I want to disable every 1st May and 25th December, I try to do with datesDisabled: ['25/12/2016'] and I have this error "TypeError: format is undefined" I change for ['25-12-2016'] or ['25 12 2016'] or ['2016/12/25'] or ['2016 12 25'] or ['2016-12-25'] and it's same error. So, I tried:

dayOff = new Date();
dayOff.setMonth(04,01);
dayOff = dayOff.toString();
$('.js-datepicker').datetimepicker({
    format: "dd MM yyyy - hh:ii",
    autoclose: true,
    language: 'fr',
    pickerPosition: "bottom-left",
    startDate: date,
    endDate: '2017-12-31',
    daysOfWeekDisabled: [2],
    datesDisabled: dayOff,
});

And I got the same error, What's wrong?


Solution

  • disabledDates must be array according to docs https://eonasdan.github.io/bootstrap-datetimepicker/#enableddisabled-dates so please try this:

    disabledDates: [
         moment("12/25/2013"),
         new Date(2013, 11 - 1, 21),
         "11/22/2013 00:53"
     ]