function getDay(day) {
// 获取日期 ±day表示day天前/后的日期 格式为 y-m-d
var today = new Date();
var targetday_milliseconds = today.getTime() + 1000 * 60 * 60 * 24 * day;
today.setTime(targetday_milliseconds);
var tYear = today.getFullYear();
var tMonth = today.getMonth();
var tDate = today.getDate();
tMonth = doHandleMonth(tMonth + 1);
tDate = doHandleMonth(tDate);
return tYear + "-" + tMonth + "-" + tDate;
}
function doHandleMonth(month) {
// 日期补0
var m = month;
if (month.toString().length == 1) {
m = "0" + month;
}
return m;
}
获取日期(y - m - d)
于 2022-11-08 15:22:17 首次发布