function getBeforeDate() {
let data = [];
let date = new Date();
let year = date.getFullYear();
let month = date.getMonth() + 1;
let today = date.getDate();
let lastMonthdays = new Date(year, month - 1, 0).getDate();
//以当前日期前一天为日期,获取前7天日期
for (let i = 0; i < 7; i++) {
if (today - 1 < 1) {
today = lastMonthdays;
if (month - 1 < 1) {
month = 12;
} else {
month = month - 1;
}
let d = month + '.' + today;
data.unshift(d);
} else {
today = today - 1;
let d = month + '.' + today;
data.unshift(d);
}
}
return data;
}
获取某天前几天的方法
最新推荐文章于 2023-09-15 17:34:43 发布