在bootstrap datetimepicker 2中设置最小日期

时间:2017-01-18 09:51:26

标签: datetimepicker

如何在 bootstrap datetimepicker 2.0 中设置最短日期。在4.0中我们可以使用minDate有没有办法在版本2.0中设置它

2 个答案:

答案 0 :(得分:0)

是使用startDate

参考更多: http://bootstrap-datepicker.readthedocs.io/en/latest/options.html#startdate

像这样使用

<div class="input-append date form_datetime" data-date="2013-02-21T15:25:00Z">
    <input size="16" type="text" value="" readonly>
    <span class="add-on"><i class="icon-calendar"></i></span>
</div>
<script type="text/javascript">
    $(".form_datetime").datetimepicker({
        format: "dd MM yyyy - hh:ii",
        startDate: "2013-02-14 10:00",
    });
</script>    

答案 1 :(得分:0)

Bootstrap datetimepicker v 4.x

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

Bootstrap datetimepicker v 2.0

$(document).ready(function() {
    var date = new Date();
    var today = new Date(date.getFullYear(), date.getMonth(), date.getDate()+1);
    $('#datePicker1').datetimepicker({
        startDate: today
    })
});