I am using typescript (Angular 5) and I have the following code:
let date = new Date(2018, 8, 17, 14, 0);
I expect "Fri Aug 17 2018 14:00:00 GMT-0400 (Eastern Daylight Time)" as the result, but instead this is what it actually returns:
Mon Sep 17 2018 14:00:00 GMT-0400 (Eastern Daylight Time)
As you can see it adds a month to the date. I've fixed it by subtracting like the following code:
let date = new Date(2018, 8 - 1, 17, 14, 0);
My question is why is this happening? Any idea? Is there any other way to fix this?