Bootstrap datetimepicker startDate不会禁用过去的日期

时间:2015-10-19 08:42:34

标签: javascript twitter-bootstrap date datetimepicker

我使用bootstrap datetimepicker,我想禁用过去几天,但$number_of_days_in_the_future = 42; // Here you can put in the number of days for which you want to display the corresponding letter, and based on your screenshot that is 42 //our case "SUN" if(AC_START_DAY=="sun"){ for($i=0; $i<$number_of_days_in_the_future; $i++){ $k = $i % 7; $weekday = mb_substr($lang["day_".$k.""],0,1,'UTF-8'); $list_day_titles.='<li class="cal_weekday"> '.$weekday.'</li>'; } } //If we chose Monday as start week. else{ if ($first_week_day == 0) $first_week_day =7; for($i=1; $i<=$number_of_days_in_the_future; $i++){ $k = $i % 7; if($k==7) $weekday = mb_substr($lang["day_0"][0],0,1,'UTF-8'); else $weekday = mb_substr($lang["day_".$k.""],0,1,'UTF-8'); $list_day_titles.='<li title="'.$lang["day_".$k.""].'"> '.$weekday.'</li>'; } } 选项不起作用:

startDate

3 个答案:

答案 0 :(得分:5)

您可能需要使用日期 时间 选择器的minDate选项:

var tomorrow = new Date();
tomorrow.setDate(tomorrow.getDate() + 1);
$("#end_at").datetimepicker({
    format: 'YYYY-MM-DD HH:mm:ss',
    minDate: tomorrow
});

答案 1 :(得分:0)

已经很久了。不推荐使用选项minDate。新的是startDate

所以你可以使用:

<script type="text/javascript">
    $(".form_datetime").datetimepicker({
        format: "dd MM yyyy - hh:ii",
        autoclose: true,
        todayBtn: true,
        startDate: "2013-02-14 10:00",
        minuteStep: 10
    });
</script> 

答案 2 :(得分:0)

startDate api将有助于禁用过去的日期

<script type="text/javascript">
     $(function() {
        $(".dates").datepicker({
        format:'dd-mm-yyyy',
        startDate:new Date(),
        autoclose:true
});
</script>