1.时间计算函数(当为月末时,后一天会自动跳到下个月的1号)
function addDate(date, days) {
var d = new Date(date);
d.setDate(d.getDate() + days);
var m = d.getMonth() + 1;
var day = d.getDate();
if (day < 10) {
day = "0" + day;
} else {
day = day;
}
if (m < 10) {
m = "0" + m;
} else {
m = m;
}
return d.getFullYear() + '-' + m + '-' + day;
}
(1)求传入时间的后一天:addDate(date,1)
(2)求传入时间的前一天:addDate(date,-1)
2.根据id给时间框赋值和取值
赋值:$('#searchtime').datebox('setValue', date);
取值:selectTime = document.getElementById("searchtime").value;