獲取當前時間前三個月的日期this
let nowDate = new Date();//獲取當前時間 // let date1 = new Date('2030-02-30'); nowDate.setMonth(nowDate.getMonth() - 3); //當前時間減去月份 let year = nowDate.getFullYear(); //獲取年 let month = nowDate.getMonth() + 1; //獲取月 let day = nowDate.getDate(); //獲取日 month = month < 10 ? "0" + month : month; //月份小於10的時候,加0 day = day < 10 ? "0" + day : day; //獲取的日小於10,加0 this.date = year.toString() + "-" + month.toString() + "-" + day.toString();