如何设置最小日期 2
How to set minDate 2
我想突出显示后天的日期,我正在使用以下代码但无法正常工作。
$('#date').datetimepicker({
timepicker: false,
format: 'Y-m-d',
formatDate: 'Y-m-d',
minDate: 2,
scrollDay: false,
scrollMonth: false,
scrollYear: false
});
将 minDate 值设置为 Date 对象
var date = new Date(); // get current date
date.setDate(date.getDate() + 2); // add two days to it
$('#date').datetimepicker({
timepicker: false,
format: 'Y-m-d',
formatDate: 'Y-m-d',
minDate: date,
scrollDay: false,
scrollMonth: false,
scrollYear: false
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-datetimepicker/2.5.4/build/jquery.datetimepicker.full.js"></script>
<link href="https://cdnjs.cloudflare.com/ajax/libs/jquery-datetimepicker/2.5.4/jquery.datetimepicker.css" rel="stylesheet" />
<input id="date" />
或者如 the documentation set '+1970/01/03'
中的最小日期到后天
$('#date').datetimepicker({
timepicker: false,
format: 'Y-m-d',
formatDate: 'Y-m-d',
minDate: '+1970/01/03',
scrollDay: false,
scrollMonth: false,
scrollYear: false
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-datetimepicker/2.5.4/build/jquery.datetimepicker.full.js"></script>
<link href="https://cdnjs.cloudflare.com/ajax/libs/jquery-datetimepicker/2.5.4/jquery.datetimepicker.css" rel="stylesheet" />
<input id="date" />
我想突出显示后天的日期,我正在使用以下代码但无法正常工作。
$('#date').datetimepicker({
timepicker: false,
format: 'Y-m-d',
formatDate: 'Y-m-d',
minDate: 2,
scrollDay: false,
scrollMonth: false,
scrollYear: false
});
将 minDate 值设置为 Date 对象
var date = new Date(); // get current date
date.setDate(date.getDate() + 2); // add two days to it
$('#date').datetimepicker({
timepicker: false,
format: 'Y-m-d',
formatDate: 'Y-m-d',
minDate: date,
scrollDay: false,
scrollMonth: false,
scrollYear: false
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-datetimepicker/2.5.4/build/jquery.datetimepicker.full.js"></script>
<link href="https://cdnjs.cloudflare.com/ajax/libs/jquery-datetimepicker/2.5.4/jquery.datetimepicker.css" rel="stylesheet" />
<input id="date" />
或者如 the documentation set
'+1970/01/03'
中的最小日期到后天
$('#date').datetimepicker({
timepicker: false,
format: 'Y-m-d',
formatDate: 'Y-m-d',
minDate: '+1970/01/03',
scrollDay: false,
scrollMonth: false,
scrollYear: false
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-datetimepicker/2.5.4/build/jquery.datetimepicker.full.js"></script>
<link href="https://cdnjs.cloudflare.com/ajax/libs/jquery-datetimepicker/2.5.4/jquery.datetimepicker.css" rel="stylesheet" />
<input id="date" />