How to disable past dates from today in bootstrap datetimepicker? [duplicate]

99封情书 提交于 2019-12-03 04:39:15
Shailendra Sharma

startDate option use in bootstrap-datepicker same option not mentioned anywhere in bootstrap-datetimepicker/Options/ doc it has minDate option for that

 $(function () {
     $('#datetimepicker').datetimepicker({  
         minDate:new Date()
      });
 });

FIddle

Atif Tariq

You can do it like this:

$(function () {
   var date = new Date();
   var today = new Date(date.getFullYear(), date.getMonth(), date.getDate());
   $('#datetimepicker').datetimepicker({ 
      minDate: today
   });
});

Another solution:

$(function () { 
  var date = new Date();
  date.setDate(date.getDate()-1);
  $('#datetimepicker').datetimepicker({ 
   startDate: date
  });
});
Manoj Salvi

I have used your fiddle and change it with following code which disables all the past dates, its working perfectly.

Here is the Fiddle and Code -

$(function () {
   $('#datetimepicker').datetimepicker({
      minDate : moment()
   });
});
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!