So I select two dates and build an array based on this.
For example:
var getDaysArray = function (s, e) { for (var a = [], d = new Date(s); d <= e; d.setDate(d.getDate() + 1)) { a.push(new Date(d)); } return a; };
var daylist = getDaysArray(new Date(datefrom), new Date(dateto));
This returns (daylist) the following:
0: Thu Mar 31 2022 00:00:00 GMT+0800 (Australian Western Standard Time) {}
1: Fri Apr 01 2022 00:00:00 GMT+0800 (Australian Western Standard Time) {}
2: Sat Apr 02 2022 00:00:00 GMT+0800 (Australian Western Standard Time) {}
3: Sun Apr 03 2022 00:00:00 GMT+0800 (Australian Western Standard Time) {}
4: Mon Apr 04 2022 00:00:00 GMT+0800 (Australian Western Standard Time) {}
5: Tue Apr 05 2022 00:00:00 GMT+0800 (Australian Western Standard Time) {}
This is correct. However when I then build these dates:
const thesedays = daylist.map((v) => v.toISOString().slice(0, 10));
This returns (thesedays) the following:
0: "2022-03-30"
1: "2022-03-31"
2: "2022-04-01"
3: "2022-04-02"
4: "2022-04-03"
5: "2022-04-04"
So it is actually using the day before (March 30 instead of 31 and April 4 instead of 5)
It is the const of thesedays that I need to adjust … just not sure how?