function getDateStr(AddDayCount) {
var dd = new Date();
dd.setDate(dd.getDate() + AddDayCount); //获取AddDayCount天后的日期
var year = dd.getFullYear();
var mon = dd.getMonth() + 1; //获取当前月份的日期
var day = dd.getDate();
return year + "-" + "0" + mon + "-" + day;
}
this.start = getDateStr(-1);
七天前时间:
function toDay() {
//获取当前日期
let myDate = new Date();
let nowY = myDate.getFullYear();
let nowM = myDate.getMonth() + 1;
let nowD = myDate.getDate();
let endDate =
nowY +
"-" +
(nowM < 10 ? "0" + nowM : nowM) +
"-" +
(nowD < 10 ? "0" + nowD : nowD); //当前日期
// console.log(endDate);
return endDate;
// this.star = endDate;
}
function toEnd() {
let myDate = new Date();
let lw = new Date(myDate - 1000 * 60 * 60 * 24 * 7); //最后一个数字7可改,7天的意思
let lastY = lw.getFullYear();
let lastM = lw.getMonth() + 1;
let lastD = lw.getDate();
let startData =
lastY +
"-" +
(lastM < 10 ? "0" + lastM : lastM) +
"-" +
(lastD < 10 ? "0" + lastD : lastD); //三十天之前日期
// console.log(startData);
return startData;
// this.end = startData;
}
let d1 = toDay()
let d2 = toEnd()
30天起始日期:
function toDay() {
//获取当前日期
let myDate = new Date();
let nowY = myDate.getFullYear();
let nowM = myDate.getMonth() + 1;
let nowD = myDate.getDate();
let endDate =
nowY +
"-" +
(nowM < 10 ? "0" + nowM : nowM) +
"-" +
(nowD < 10 ? "0" + nowD : nowD); //当前日期
// console.log(endDate);
return endDate;
// this.star = endDate;
}
function toEnd() {
let myDate = new Date();
let lw = new Date(myDate - 1000 * 60 * 60 * 24 * 30); //最后一个数字30可改,30天的意思
let lastY = lw.getFullYear();
let lastM = lw.getMonth() + 1;
let lastD = lw.getDate();
let startData =
lastY +
"-" +
(lastM < 10 ? "0" + lastM : lastM) +
"-" +
(lastD < 10 ? "0" + lastD : lastD); //三十天之前日期
// console.log(startData);
return startData;
// this.end = startData;
}
let d1 = toDay()
let d2 = toEnd()