Jackson Collins
Jackson Collins

Reputation: 120

Bootstrap DateTimePicker, setting minDate not working

I've seen answers that use either, new Date() or moment() to declare minDate and been marked as the answer but in my case neither worked. E.g. How to disable past dates from today in bootstrap datetimepicker?

The code is:

$('.datePicker').datetimepicker({
    //format: "HH:ii P, dd M yyyy",
    //format: 'YYYY-MM-DD',
    //minDate: new Date(),
    //minDate: moment(),
    minuteStep: 1,
    showMeridian: true,
    todayBtn: true
});

Bootstrap v3.3.7 is being used and it looks like:

enter image description here

As you can see the dates prior to the 16th (today) aren't being disabled. Could this be due to my bootstrap version?

Upvotes: 0

Views: 868

Answers (1)

VincenzoC
VincenzoC

Reputation: 31482

minDate is for eonasdan-datetimepicker, while tarruda's datetimepicker uses startDate:

Options

These are the default options for initializing the widget:

$.fn.datetimepicker.defaults = {
  startDate: -Infinity,      // set a minimum date
  endDate: Infinity          // set a maximum date
};

Upvotes: 3

Related Questions