function initDate() {
let _now = new Date();
const startDate = new Date(`${_now.getFullYear()}/${_now.getMonth() + 1}/${_now.getDate()}`),
endDate = new Date(`${_now.getFullYear()}/${_now.getMonth() + 1}/${_now.getDate()}`);
startDate.setDate(endDate.getDate() -1); //前一天
endDate.setDate(endDate.getDate() + 1); //后一天
};
根据给定日期计算年月日
function CreateDate(date){
const weekKey = ['日', '一', '二', '三', '四', '五', '六'];
const model = {
date,
day:date.getDate(),
month:date.getMonth() + 1,
year: date.getFullYear(),
weekday: date.getDay(),
weekName: weekKey[date.getDay()],
};
}
网友评论