1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
| fz(num) { if (num < 10) { num = "0" + num; } return num },
getYMD(value) { return [value.getFullYear(), this.fz(value.getMonth() + 1), this.fz(value.getDate())].join("-"); },
getDate(value) { let strArr = value.split('-'); return new Date(strArr[0], strArr[1] - 1, strArr[2]); },
getDays(day1, day2) { let st = this.getDate(day1); let et = this.getDate(day2);
let retArr = [];
let yyyy = st.getFullYear(), mm = st.getMonth(), dd = st.getDate();
while (st.getTime() != et.getTime()) { st = new Date(yyyy, mm, dd++); retArr.push(this.getYMD(st)); }
return retArr; },
let dateArr = this.getDays('2019-01-01', '2019-01-20'); console.log(dateArr);
|