如何在1周后设置开始日期? 我使用这个日历http://www.eyecon.ro/bootstrap-datepicker/`var nowTemp = new Date(); var now = new Date(nowTemp.getFullYear(),nowTemp.getMonth(),nowTemp.getDate(),0,0,0,0);
var checkin = $('#dpd1').datepicker({
onRender: function(date) {
return date.valueOf() < now.valueOf() ? 'disabled' : '';
}
}).on('changeDate', function(ev) {
if (ev.date.valueOf() > checkout.date.valueOf()) {
var newDate = new Date(ev.date)
newDate.setDate(newDate.getDate() + 1);
checkout.setValue(newDate);
}
checkin.hide();
$('#dpd2')[0].focus();
}).data('datepicker');
var checkout = $('#dpd2').datepicker({
onRender: function(date) {
return date.valueOf() <= checkin.date.valueOf() ? 'disabled' : '';
}
}).on('changeDate', function(ev) {
checkout.hide();
}).data('datepicker');`
答案 0 :(得分:-1)
用它来设置变量&#34; now&#34;到当前日期后7天:
var nowTemp=new Date();
var oneWeekAfter = new Date();
oneWeekAfter.setDate(nowTemp.getDate()+7);
oneWeekAfter.getDate();
var now = new Date(nowTemp.getFullYear(), nowTemp.getMonth(), oneWeekAfter.getDate(), 0, 0, 0, 0);