我想知道明天的日期,但是这项工作不正确。我不明白,这是什么问题,我分割了日期,以获取真实的日期格式,检查复选框是否已选中并添加到getdate 1天,并根据需要调整日期
function doLateCheckOut(checkbox){
var end_date = $('[name="end_date"]').val();
var dateArr = end_date.split(".");
var date = new Date(dateArr[2]+'-'+dateArr[1]+'-'+dateArr[0]);
if(checkbox.checked) {
date.setDate(date.getDate() + 1);
}
else{
date.setDate(date.getDate() - 1);
}
var day = date.getDate();
var monthIndex = date.getMonth();
var year = date.getFullYear();
day = day + '';
if (day.length == 1) {
day = "0" + day;
}
if (monthIndex < 10) {
monthIndex = "0" + (monthIndex+1);
}
var latedate = day + "." + monthIndex + "." + year;
$('[name="end_date"]').val(latedate);
console.log(latedate);
}