浅时光吖~  
生活明朗,万物可爱,加油~

 

var now = new Date(); //当前时间

var nowMonth = now.getMonth(); 

var nowYear = now.getFullYear(); 

 

1.当前时间前一天(昨天)

var preDate = new Date(now.getTime() - 24 * 60 * 60 * 1000); 

 

2.当前时间后一天(明天)

var nextDate = new Date(now.getTime() + 24 * 60 * 60 * 1000); 

 

3.本月月初零时

var monthStartDate = new Date(nowYear, nowMonth, 1);

 

4.本月月末零时

var monthEndDate = new Date(nowYear, nowMonth + 1, 0);

 

5.当天零时

var nowStartTime = new Date(now.setHours(0,0,0,0))

 

6.最近7天

var sevenDays = new Date(now.getTime() - 24 * 60 * 60 * 1000 * 7); 

 

7.最近30天

var thirtyDays = new Date(now.getTime() - 24 * 60 * 60 * 1000 * 30); 

 

 
posted on 2020-05-11 14:39  浅时光吖~  阅读(217)  评论(0编辑  收藏  举报