Open wangyuan0108 opened 4 years ago
const dateList = [...Array(7).keys()].map(days => {
let t = new Date(Date.now() - 86400000 * days);
let str = `${t.getFullYear()}年${t.getMonth() + 1}月${t.getDate()}日`;
return str;
});
console.log(dateList);
function fun_date(aa){
var date1 = new Date(),
time1=date1.getFullYear()+"-"+(date1.getMonth()+1)+"-"+date1.getDate();//time1表示当前时间
var date2 = new Date(date1);
date2.setDate(date1.getDate()+aa);
var time2 = date2.getFullYear()+"-"+(date2.getMonth()+1)+"-"+date2.getDate();
}
fun_date(7);//7天后的日期
fun_date(-7);//7天前的日期