获取当天日期以及指定日期
function addDate() {
let nowDate = new Date(), nowDate2 = new Date();
nowDate2.setDate(nowDate.getDate()-7); // setDate()方法设置一个月的某一天
return [
nowDate2.getFullYear() + '-'+ (nowDate2.getMonth() + 1) + '-' + nowDate2.getDate(),
nowDate.getFullYear() + '-' + (nowDate.getMonth() + 1) + '-' + nowDate.getDate()
]
}
console.log(addDate()) // ["2020-3-17", "2020-3-24"]