I know that Javascript Date is really weird, to not say other thing but what I see in the example below is annoying and I don’t really know the reasons why.
/*
* It will be considered as "2018-10-01", so if we consider the zero-index
* way to see months we should at least see something like 2018-09-01T00:00:00.000Z
* but we do see 2018-10-01T00:00:00.000Z
*/
const d1 = new Date("2018-10");
console.log(d1.getMonth()); // output 8 - not 9 or 10
console.log(d1.getDate()); // output 30 - not 01
console.log(d1.getTime()); // output 1538352000000
console.log(new Date(1538352000000)); // output 2018-10-01T00:00:00.000Z ... WHAT?
I’m so lost to understand why I got 8 and 30 in the example above.
I’m expecting to see correct day and month information.
And yes, I know we have date-fns and moment, but I really want to know the issue here.