How to disable date before today in datetimepicker

2019-09-20 12:32发布

Demo and full code is like this : http://fiddle.jshell.net/oscar11/dgb09c5c/5/

My Javascript code is like this :

$('#time-start').datetimepicker({
    format: 'yyyy-mm-dd hh:ii:ss',
    autoclose: true,
    pickerPosition: "bottom-left",
    maxView: 3,
    minuteStep: 1,
    minDate: new Date()
})

How to disable date before today?

I add minDate: new Date(), but it's not working

Any solution to solve my problem?

1条回答
孤傲高冷的网名
2楼-- · 2019-09-20 13:27

From Bootstrap datetime picker documentation

$.fn.datetimepicker.defaults = {
  maskInput: true,           // disables the text input mask
  pickDate: true,            // disables the date picker
  pickTime: true,            // disables de time picker
  pick12HourFormat: false,   // enables the 12-hour format time picker
  pickSeconds: true,         // disables seconds in the time picker
  startDate: -Infinity,      // set a minimum date
  endDate: Infinity          // set a maximum date
};

I modified your Fiddle. Is it what you are looking for? http://fiddle.jshell.net/dgb09c5c/6/

查看更多
登录 后发表回答