Bootstrap datetimepicker disable past dates & curr

2019-06-11 03:45发布

问题:

I want to disable past dates & current date, but I'm unable to disable current date. Below my code, only disables past dates, please correct my code if I'm wrong, thanks in advance.

 <script>
   $('#datetimepicker1').datetimepicker({
       minDate: moment(1, 'h')
    });
</script>

回答1:

Try disabledDates with minDate:

$('#datetimepicker').datetimepicker({  
 minDate:new Date(),
 disabledDates: [new Date()]
});

Fiddle



回答2:

use the minDate and disabledDates:

    $('#datetimepicker').datetimepicker({  
      minDate:new Date(),
      disabledDates: [new Date()]
     });