直接拿走
getDateRange(dateNow,intervalDays,bolPastTime){
let oneDayTime = 24 * 60 * 60 * 1000;
let list = [];
let lastDay;
if(bolPastTime == true){
lastDay = new Date(dateNow.getTime() - intervalDays * oneDayTime);
list.push(this.formateDate(lastDay));
list.push(this.formateDate(dateNow));
}else{
lastDay = new Date(dateNow.getTime() + intervalDays * oneDayTime);
list.push(this.formateDate(dateNow));
list.push(this.formateDate(lastDay));
}
return list;
},
formateDate(time)
{
let year = time.getFullYear()
let month = time.getMonth() + 1
let day = time.getDate()
if (month < 10)
{
month = '0' + month
}
if (day < 10)
{
day = '0' + day
}
return year + '-' + month + '-' + day + ''
}
var date = new Date();
var myDate = this.getDateRange(date,6,true);//获取近一周日期范围
var myDate = this.getDateRange(date,30,true);//获取近一个月日期范围
var myDate = this.getDateRange(date,0,true);//获取今天日期范围
var myDate = this.getDateRange(date,1,true);//获取昨天日期范围
var myDate = this.getDateRange(date,6,false);//获取下一周日期范围
var myDate = this.getDateRange(date,30,false);//获取下一个月日期范围