data(){
return {
StrStartTime:'',
StrEndTime:'',
add_start_time:'',
add_end_time:''
}
}
method(){
// 执行这个方法 打印一下数据
serachToday() {
var _this = this;
_this.add_start_time= new Date(_this.StrStartTime);
_this.add_end_time= new Date(_this.StrEndTime);
this.dateList = _this.getEveryDay(_this.StrStartTime, _this.StrEndTime);
// console.log(this.dateList) // ['2023-12-20','2023-12-21','2023-12-22']
},
startDay(currentDay) {
let d = new Date(currentDay);
d = +d + 1000 * 60 * 60 * 24;
d = new Date(d);
return d.getFullYear() + "-" + (d.getMonth() + 1) + "-" + d.getDate();
},
endDate(oldDate) {
let arr = oldDate.split("-");
arr["1"] = arr["1"].length == 1 ? "0" + arr["1"] : arr["1"];
arr["2"] = arr["2"].length == 1 ? "0" + arr["2"] : arr["2"];
return dateArr.join("-");
},
getEveryDay(startDate, endData) {
var _this = this;
let searchDateList = [startDate];
let dayCount = (new Date(endData) - new Date(startDate)) / (1000 * 60 * 60 * 24);
for (let i = 0; i < dayCount; i++) {
let currentDay = _this.startDay(searchDateList[i]);
currentDay = _this.endDate(currentDay);
searchDateList.push(currentDay);
}
return searchDateList;
},
}
09-17
574
12-01
1466
05-17