How to disable specific dates in bootstrap-datetimepicker-master?

21,440

That will depend on which plugin you are using, there are several bootstrap-datetimepicker projects.

If bootstrap-datetimepicker-master is this one, based on this fork you can use datesDisabled:

datesDisabled

String, Array. Default: []

Array of date strings or a single date string formatted in the given date format

You can check it out here.

If you are using other plugin you need to have a look to its docs, but I guees more of the projects have datesDisabled available.

Remember to specify the dates in the format that you have set, in your case: 'YYYY/MM/DD'.

Example:

$(".datepicker").datetimepicker({
    format: 'YYYY/MM/DD hh:ii',
    startDate: '2016/08/19 10:00',
    daysOfWeekDisabled: [1,2,3,4,5],
    datesDisabled: ['2016/08/20'],
    autoclose: true,    
});
Share:
21,440
sekaraja
Author by

sekaraja

Updated on July 09, 2022

Comments

  • sekaraja
    sekaraja almost 2 years
    $(".datepicker").datetimepicker({
        format: 'MM dd hh:ii P',
        startDate: "2016-08-19 10:00",
        daysOfWeekDisabled: [1,2,3,4,5],
        autoclose: true,    
    });
    

    How to disable specific date in datetime picker?

  • sekaraja
    sekaraja over 7 years
    yah,its correct datesDisabled but its through error, bootstrap-datetimepicker.js:1608 Uncaught TypeError: Cannot read property 'parts' of undefined
  • sekaraja
    sekaraja over 7 years
    format: 'YYYY/MM/D', daysOfWeekDisabled: [1,2,3,4,5], datesDisabled:["2016-08-21"],
  • sekaraja
    sekaraja over 7 years
    bootstrap-datetimepicker.js:1491 Uncaught Error: Invalid format type.
  • David
    David over 7 years
    That is because the formats are not matching. As I pointed out in my answer, if you pass format: 'YYYY/MM/DD' you need to pass datesDisabled: ['2016/08/21'] and not datesDisabled: ['2016-08-21']