-
Notifications
You must be signed in to change notification settings - Fork 30.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
First day and last day in a month not behaving like in the browser. (Date object) #9333
Comments
It looks like it's possibly a difference in timezones (between node and the browser)? I get the same result both in the browser and in node v6.9.1 on the same machine. What do you see if you log |
Interesting. I assume that this is a simple off by one bug but I'm not familiar with the codebase enough in order to mess with it at this point.
gives the wanted year-month-date: Same result (regarding the year-month-date values) can be obtained by:
Thanks :) |
Ok, so node agrees with the browser then. There is no discrepancy here. It's a matter of timezones. The long form ( The UTC dates make sense because the hour is not passed to the constructor, so the default of midnight is used. Since the timezone (for |
@mscdex Appreciate the super clear explanation. |
This is the code I use to get the first day and the last day of the month in the browser:
The browser gives the following (correct) results:
Sat Oct 01 2016 00:00:00 GMT+0200 (Central Europe Daylight Time)
Mon Oct 31 2016 00:00:00 GMT+0100 (Central Europe Standard Time)
Yet the Node runtime gives these results:
2016-09-30T22:00:00.000Z
2016-10-30T23:00:00.000Z
Disregarding the formatting, the numerical values for month and day aren't what they are when the same code is executed in the browser.
Has anyone else noticed this?
Thanks.
The text was updated successfully, but these errors were encountered: