how to disable previous date in bootstrap datepicker?

Posted by w3diy - 5 months ago

How to disable past dates from today in bootstrap datetimepicker?

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

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
  });
});