Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Set minDate to Today in Bootstrap DateTimePicker

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()
    });
like image 954
Giantsfan542 Avatar asked Nov 23 '14 22:11

Giantsfan542


People also ask

How do you set MinDate on DateTimePicker?

Step 1: Create a DateTimePicker using the DateTimePicker() constructor is provided by the DateTimePicker class. // Creating a DateTimePicker DateTimePicker dt = new DateTimePicker(); Step 2: After creating DateTimePicker, set the MinDate property of the DateTimePicker provided by the DateTimePicker class.

Does bootstrap 4 have a DateTimePicker?

Bootstrap 4 compatible Datetimepicker with Material Design UI. Datetimepicker component allows user to select a date from a calendar and time from a visual analog clock; it also accepts values via direct input. You can find a variety of date and time picker examples here.


1 Answers

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()
});
like image 86
Bart Jedrocha Avatar answered Oct 12 '22 16:10

Bart Jedrocha