Bootstrap datetimepicker disable past dates & current date?

守給你的承諾、 提交于 2019-12-23 01:44:27

问题


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


来源:https://stackoverflow.com/questions/43610281/bootstrap-datetimepicker-disable-past-dates-current-date

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