//获取七天日期函数
function getDay(day){
let today = new Date();//获得时间戳
let targetday_milliseconds=today.getTime() + 1000*60*60*24*day;//获得新的时间戳
today.setTime(targetday_milliseconds); //注意,这行是关键代码转化为javascript的日期
let tYear = today.getFullYear();
let tMonth = today.getMonth();
let tDate = today.getDate();
tMonth = doHandleMonth(tMonth + 1);
tDate = doHandleMonth(tDate);
return tYear+"-"+tMonth+"-"+tDate;
}
//单日月规格化 加0
function doHandleMonth(month){
let m = month;
if(month.toString().length == 1){
m = "0" + month;
}
return m;
}
09-20
1094
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
07-09
245
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
12-31
1004
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
03-27
553
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
10-06
3650
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)