获取当前时间前三个月的日期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();