20

I'm using Bootstrap DateTime Picker (http://eonasdan.github.io/bootstrap-datetimepicker/) and I've found the basic option to set a minDate; but, I can't get it to set to today to save my life. I've tried things like Date(); but, nothing working. Anyone have any ideas?

Example

    $('#date').datetimepicker({
        pickTime: false,
        icons: {
                time: "fa fa-clock-o",
                date: "fa fa-calendar",
                up: "fa fa-arrow-up",
                down: "fa fa-arrow-down"
            },
        startDate: new Date()
    });
Giantsfan542
  • 271
  • 1
  • 4
  • 8

3 Answers3

58

If you're using the latest version, the minDate option is what you'll need to set. Here is a JSFiddle with a working example. Hope this helps.

$('#date').datetimepicker({
    pickTime: false,
    icons: {
      time: "fa fa-clock-o",
      date: "fa fa-calendar",
      up: "fa fa-arrow-up",
      down: "fa fa-arrow-down"
    },
    minDate: moment()
});
Bart Jedrocha
  • 11,450
  • 5
  • 43
  • 53
11
$(".datepicker-custom-flight").datepicker({
    startDate: "dateToday"
})
mickmackusa
  • 43,625
  • 12
  • 83
  • 136
Jah Yusuff
  • 729
  • 7
  • 5
  • This answer is missing an explanation / reference to documentation. – mickmackusa Mar 18 '21 at 04:22
  • @mickmackusa I was wondering the same thing. startDate seems to be documented there: https://bootstrap-datepicker.readthedocs.io/en/latest/options.html#startdate . Regarding the format, it seems just putting startDate: "today" or startDate: "yesterday" both work. I'm looking for what is doing the parsing. – Wadih M. Aug 10 '21 at 19:41
4

You can use this code, by avoiding additional scripts.

Example

var todayDate = new Date().getDate();
var endD= new Date(new Date().setDate(todayDate - 15));
var currDate = new Date();
$('.datepicker').datepicker({
    format: 'dd/mm/yyyy',                       
    autoclose: true,
    startDate : endD,
    endDate : currDate
});
shijinmon Pallikal
  • 964
  • 11
  • 19