js获取后七天的数据,如通过获取一周的周一的时间,然后计算出周日的日期
程序员文章站
2024-03-07 13:08:39
...
getSevenDay(date){
//
let today = new Date(date);
let seven_milliseconds = today.getTime()+1000*60*60*24*6;
let sevenDay = new Date();
sevenDay.setTime(seven_milliseconds);
let strYear=sevenDay.getFullYear();
let strDay=sevenDay.getDate();
let strMonth=sevenDay.getMonth()+1;
if(strMonth<10)
{
strMonth="0"+strMonth;
}
if (strDay<10){
strDay = "0"+strDay;
}
let strSevenDay=strYear+"-"+strMonth+"-"+strDay;
return strSevenDay
}
上一篇: MVP一路向北
下一篇: 腾讯2017秋招笔试编程题