Open CyberCookie opened 6 months ago
I am on 14.2.1 on macos Intel I am not able to reproduce the above with node 21.5.0
@preveen-stack
You should probably set another timezone to reproduce it
My timezone is Eastern European Standard Time
We managed to reproduce it on 4 different macs
I'm upgrading some old FreeBSD compute hosts and seeing a similar issue. I'm in PDT and on all platforms Intl.DateTimeFormat().resolvedOptions().timeZone=='America/Los_Angeles'
and they report the correct local time via date
. On Windows with node 20.12.2, new Date().getTimezoneOffset()==420
and the same on FreeBSD 12.2-RELEASE-p7 with node 16.10.0 (what the old hosts are running). On FreeBSD 14.0-RELEASE-p6 with node 20.12.2 new Date().getTimezoneOffset()==540
... Interestingly setting process.env.TZ
(which is undefined) explicitly to 'America/Los_Angeles'
results in the correct answer (420) on FreeBSD 14, even though this is what it already reports as the time zone.
Details
(new Date(0)).getTimezoneOffset() produces different output on different environments.
Correct output (
-180
) is produced on: Mac OS 14.2 Chrome 119.0 Linux 6.5 Fedora 38 NodeJS REPL / Chrome 119.0 Windows 11 NodeJS REPL / Chrome 119.0Incorrect output (
-120
) is produced on: Mac OS 14.2 NodeJS REPLNode.js version
v20.9.0
Example code
(new Date(0)).getTimezoneOffset()
Operating system
Mac OS 14.2
Scope
runtime
Module and version
Not applicable.