Plugin bootstrap-material-datetimepicker disable days of the week


I'm using the Timepicker plugin called bootstrap-material-datetimepicker:

( link ).

I'd like to be able to turn off some days of the week, or just turn on Wednesdays and Fridays but I can not, can someone give me a hand? Thank you

asked by Laranja Mecânica 20.04.2016 в 10:55

4 answers




I made a pull request to add this option to the plugin, the authors validated and added the version that is already available on the date   05/05/2016.


Add option to enable specified days # 98

As the above people mentioned, there is no such behavior, but you can easily customize and add your behaviors to any plugin, just understand how it works.


Parameter-enabled days that remain enabled.

      time: false,
      clearButton: true,
      enableDays: [3, 5]

Starting at index 0 [3,5] are equivalent to Fourth and Sixth.

Now open the file: bootstrap-material-datetimepicker.js

Add the following behavior:

enableDays: function() {
  var enableDays = this.params.enableDays;
  if (enableDays) {
    $(".dtp-picker-days tbody tr td").each(function() {
      if (!(($.inArray($(this).index(), enableDays)) >= 0)) {
          "background": "#e3e3e3",
          "cursor": "no-drop",
          "opacity": "0.5"

Looking like this:



03.05.2016 / 16:32

This plugin does not support this functionality. To do this you need to change the plugin code or look for another alternative. I made a change to the plugin constructHTMLCalendar function to perform this check you requested:

constructHTMLCalendar: function(date, calendar)		{
var _template = "";

if(calendar.days[i] != 0)
	if(this.isBeforeMaxDate(moment(calendar.days[i]), false, false) === false || this.isAfterMinDate(moment(calendar.days[i]), false, false) === false)
		_template += '<span class="dtp-select-day">' + moment(calendar.days[i]).locale(this.params.lang).format("DD") + '</span>';
		var quarta = 3;
		var sexta = 5;
			if(moment(calendar.days[i]).locale(this.params.lang).format("DD") === moment(this.currentDate).locale(this.params.lang).format("DD"))
				if(new Date(calendar.days[i]._d).getDay() == quarta || new Date(calendar.days[i]._d).getDay() == sexta){
					_template += '<a href="javascript:void(0);" class="dtp-select-day selected">' + moment(calendar.days[i]).locale(this.params.lang).format("DD") + '</a>';	
					_template += '<a class="selected">' + moment(calendar.days[i]).locale(this.params.lang).format("DD") + '</a>';
				if(new Date(calendar.days[i]._d).getDay() == quarta || new Date(calendar.days[i]._d).getDay() == sexta){
					_template += '<a href="javascript:void(0);" class="dtp-select-day">' + moment(calendar.days[i]).locale(this.params.lang).format("DD") + '</a>';
					_template += '<a disabled="disabled">' + moment(calendar.days[i]).locale(this.params.lang).format("DD") + '</a>';	

		_template += '</td>';
_template += '</tr></tbody></table>';

return _template;

You can see that I created two fourth and sixth variables and use them in if to remove or not the 'dtp-select-day' class (which is used to identify the days that can be selected) and the day's href is being built in the calendar. If you want you can apply it to your bootstrap-material-datetimepicker.js and see if that suits you.

03.05.2016 в 14:08

Using eonasdan Bootstrap 3 Datepicker v4 , they already implement functionality to disable specific dates for the user not to select.

Follow the plugin: link

Enabled / Disabled Dates

   defaultDate: "11/1/2013",
   disabledDates: [
      new Date(2013, 11 - 1, 21),
      "11/22/2013 00:53"

In this case, dates 21 and 22 of month 11 of Year 2013 are disabled.

03.05.2016 в 14:36

Looking at the documentation in their Git, they do not have this functionality. What you can do is open an issue for them: link

Until then, what you can do is look for another tool or wait for their response.

Here are some examples of other tools:



03.05.2016 в 14:00