2
$(".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?

2
  • I think that library itself have example in github page(README) github.com/smalot/bootstrap-datetimepicker Commented Aug 20, 2016 at 8:00
  • its not give any example for disable specific dates.. Commented Aug 20, 2016 at 9:28

2 Answers 2

7

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, }); 
Sign up to request clarification or add additional context in comments.

4 Comments

yah,its correct datesDisabled but its through error, bootstrap-datetimepicker.js:1608 Uncaught TypeError: Cannot read property 'parts' of undefined
format: 'YYYY/MM/D', daysOfWeekDisabled: [1,2,3,4,5], datesDisabled:["2016-08-21"],
bootstrap-datetimepicker.js:1491 Uncaught Error: Invalid format type.
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']
0

I got the some problem and I think my format is matching

$('.form_date').datetimepicker({ format: 'yyyy-mm-dd', todayBtn: 1, autoclose: 1, startView: 2, minView: 2, forceParse: 0, daysOfWeekDisabled: [0, 6], datesDisabled: ['2016-09-16'], }); 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.