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,
});
Author by
sekaraja
Updated on July 09, 2022Comments
-
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?
-
wolendranh over 7 yearsI think that library itself have example in github page(README) github.com/smalot/bootstrap-datetimepicker
-
sekaraja over 7 yearsits not give any example for disable specific dates..
-
-
sekaraja over 7 yearsyah,its correct datesDisabled but its through error, bootstrap-datetimepicker.js:1608 Uncaught TypeError: Cannot read property 'parts' of undefined
-
sekaraja over 7 yearsformat: 'YYYY/MM/D', daysOfWeekDisabled: [1,2,3,4,5], datesDisabled:["2016-08-21"],
-
sekaraja over 7 yearsbootstrap-datetimepicker.js:1491 Uncaught Error: Invalid format type.
-
David over 7 yearsThat is because the formats are not matching. As I pointed out in my answer, if you pass
format: 'YYYY/MM/DD'
you need to passdatesDisabled: ['2016/08/21']
and notdatesDisabled: ['2016-08-21']