代码
Days(20)//从今天开始20天时间
Days(days) {
if(days == '' || days == null || days == undefined || typeof days != "number"){
return false;
}
let weekday = ['周日', '周一', '周二', '周三', '周四', '周五', '周六']
let res = [];//返回数据
let today = new Date().getTime();//今天
for(let i = 0; i < days; i++){
let list={
month:null,
day:null,
currDay:null,
flag:false
};
let _day = new Date(today + 86400000 * i),
year = _day.getFullYear(),
month = (_day.getMonth() + 1),
day = _day.getDate();
let index = _day.getDay()
let currDay = weekday[index]
month < 10 ? '0' + month : month;
day < 10 ? '0' + day : day;
list.month=month;
list.day=day;
list.currDay=currDay;
res.push(list);
}
res[0].currDay='今天';
res[1].currDay='明天';
return res;
}