Bootstrap datetimepicker startDate 不禁用过去的日期
Bootstrap datetimepicker startDate does not disable past dates
我使用 bootstrap 日期时间选择器,我想禁用过去几天,但 startDate
选项不起作用:
var now = new Date();
var tomorrow = now.getFullYear() + "-" + (now.getMonth() + 1) + "-" + (now.getDate() + 1) + " " + now.getHours() + ":" + now.getMinutes() + ":" + now.getSeconds();
$('#end_at').datetimepicker({
format: 'YYYY-MM-DD hh:mm:ss',
startDate: tomorrow
});
您可能需要使用日期时间选择器的minDate
选项:
var tomorrow = new Date();
tomorrow.setDate(tomorrow.getDate() + 1);
$("#end_at").datetimepicker({
format: 'YYYY-MM-DD HH:mm:ss',
minDate: tomorrow
});
好久不见了。选项 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>
startDate api 将有助于禁用过去的日期
<script type="text/javascript">
$(function() {
$(".dates").datepicker({
format:'dd-mm-yyyy',
startDate:new Date(),
autoclose:true
});
</script>
我使用 bootstrap 日期时间选择器,我想禁用过去几天,但 startDate
选项不起作用:
var now = new Date();
var tomorrow = now.getFullYear() + "-" + (now.getMonth() + 1) + "-" + (now.getDate() + 1) + " " + now.getHours() + ":" + now.getMinutes() + ":" + now.getSeconds();
$('#end_at').datetimepicker({
format: 'YYYY-MM-DD hh:mm:ss',
startDate: tomorrow
});
您可能需要使用日期时间选择器的minDate
选项:
var tomorrow = new Date();
tomorrow.setDate(tomorrow.getDate() + 1);
$("#end_at").datetimepicker({
format: 'YYYY-MM-DD HH:mm:ss',
minDate: tomorrow
});
好久不见了。选项 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>
startDate api 将有助于禁用过去的日期
<script type="text/javascript">
$(function() {
$(".dates").datepicker({
format:'dd-mm-yyyy',
startDate:new Date(),
autoclose:true
});
</script>