Angular 5 Error with dates [on hold]


Angular 5 Error with dates [on hold]



After having been puzzled for a while for the reason my dates were messed up, I made this simple test:


var dt: Date = new Date(2008, 6, 30);
console.log("test: " + dt);



the result of the console was:



test: Wed Jul 30 2008 00:00:00 GMT+0200 (ora legale Europa occidentale)



which is exactly one month more than expected. Can anyone replicate?
Do months start with 0 in Angular?



This question appears to be off-topic. The users who voted to close gave these specific reasons:





The Date class has nothing to do with Angular. And yes, its months start at 0. Why not read the documentation? developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/… It clearly says: Note: The argument monthIndex is 0-based. This means that January = 0 and December = 11.
– JB Nizet
Jun 30 at 14:14






Nice Convention!! Against all odds
– user1238784
Jun 30 at 14:18





It's not nice. It's absolutely terrible. But so is the rest of the Date class. And it's JavaScript...
– JB Nizet
Jun 30 at 14:20





yes my comment was out of irony...
– user1238784
Jun 30 at 14:23





Possible duplicate of javascript is creating date wrong month
– Alessandro Da Rugna
Jun 30 at 22:44




Popular posts from this blog

How to input without newline? (Python)

C++ thread error: no type named ‘type’ MINGW

Analog for TagView in flutter