What is going on with the snippet below? I'm trying to build an array of strings as dates starting from a day in the past. I'm able to do it for the whole 2019 year for example. But when I start in 2017-01-01
somehow I CANNOT increment the date past 2017-03-26
.
I can increment 2017-03-27
to 2017-03-28
without a problem. Why is this happening?
const currentDay = "2017-01-01";
const nextDay = new Date(new Date(currentDay).setDate(new Date(currentDay).getDate() + 1)).toISOString().split("T")[0];
console.log('currentDay: ' + currentDay);
console.log('nextDay: ' + nextDay);
const currentDay2 = "2017-03-26";
const nextDay2 = new Date(new Date(currentDay2).setDate(new Date(currentDay2).getDate() + 1)).toISOString().split("T")[0];
console.log('currentDay2: ' + currentDay2);
console.log('nextDay2: ' + nextDay2 + '<------ DOES NOT INCREMENT');
const currentDay3 = "2017-03-27";
const nextDay3 = new Date(new Date(currentDay3).setDate(new Date(currentDay3).getDate() + 1)).toISOString().split("T")[0];
console.log('currentDay3: ' + currentDay3);
console.log('nextDay3: ' + nextDay3);
I don't think this is an issue with my environment, but anyway, here's what I'm getting:
Are you guys getting something different?