//星期
function formatWeek(n){
let myDate = new Date();
let theDay=myDate.getDay()
let week=[‘星期一‘,‘星期二‘,‘星期三‘,‘星期四‘,‘星期五‘,‘星期六‘,‘星期日‘]
let year=myDate.getFullYear();
let month=myDate.getMonth()+1;
let day=myDate.getDate();
return week[n]
}
//日期
function formatDay(AddDayCount) {
let myDate = new Date();
myDate.setDate(myDate.getDate()+AddDayCount);//设置当前日期加几天(减几天)
let y = myDate.getFullYear();
let m = myDate.getMonth()+1;
let d = myDate.getDate();
return y+"年"+m+"月"+d+"日";
}
for(let i=0;i<7;i++){
let myDate = new Date();
let theDay=myDate.getDay()
if(i<theDay){
if(i==theDay-1){
document.write(formatDay(i-(theDay-1))+‘今天‘+‘............‘)
}else{
document.write(formatDay(i-(theDay-1))+formatWeek(i)+‘............‘)
}
}else {
document.write(formatDay(i-(theDay-1))+formatWeek(i)+‘............‘)
}
}