function get7Days(){
//获取系统当前时间
var now = new Date();
var nowTime = now.getTime() ;
var oneDayTime = 24*60*60*1000 ;
for(var i = 0 ; i < 7 ; i++){
//显示周一
var ShowTime = nowTime + i*oneDayTime ;
// var ShowTime = nowTime + (i+1)*oneDayTime ;
//初始化日期时间
var myDate = new Date(ShowTime);
var year=myDate.getFullYear();
var month=myDate.getMonth()+1;
var date=myDate.getDate();
console.log(year+"-"+month+"-"+date)
var str = "星期" + "日一二三四五六".charAt(myDate.getDay());
console.log(str)
}
}
[Web浏览器] "当前时间==2019-07-19"
[Web浏览器] "2019-7-19"
[Web浏览器] "星期五"
[Web浏览器] "2019-7-20"
[Web浏览器] "星期六"
[Web浏览器] "2019-7-21"
[Web浏览器] "星期日"
[Web浏览器] "2019-7-22"
[Web浏览器] "星期一"
[Web浏览器] "2019-7-23"
[Web浏览器] "星期二"
[Web浏览器] "2019-7-24"
[Web浏览器] "星期三"
[Web浏览器] "2019-7-25"
[Web浏览器] "星期四"