时间:2023-7-13 作者:网络剑客 分类: other
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)
}
}