Skip to content
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

Node and Chrome output different results #28

Open
oaleynik opened this issue Nov 5, 2024 · 0 comments
Open

Node and Chrome output different results #28

oaleynik opened this issue Nov 5, 2024 · 0 comments

Comments

@oaleynik
Copy link

oaleynik commented Nov 5, 2024

Hi there 👋🏻

First of all - thanks for bringing timezones support to date-fns 🙌🏻

I'm pretty sure I missed something. However, I can't get these to work in Chrome.

// CHROME
fromUnixTime(1732204800, { in: tz('America/Denver') }).toString()
// 'Thu Nov 21 2024 18:00:00 GMT+0200 (Eastern European Standard Time)'
new TZDate(1732204800000, 'America/Denver').toString()
// 'Thu Nov 21 2024 09:00:00 GMT-0700 (Mountain Standard Time)'
format(fromUnixTime(1732204800, { in: tz('America/Denver') }), 'MM/dd/yyyy h:mm a z')
// '11/21/2024 6:00 PM GMT+2'
format(new TZDate(1732204800000, 'America/Denver'), 'MM/dd/yyyy h:mm a z')
// '11/21/2024 6:00 PM GMT+2'

Node has it as I would naturally expect:

// NODE
fromUnixTime(1732204800, { in: tz('America/Denver') }).toString()
// Thu Nov 21 2024 09:00:00 GMT-0700 (Mountain Standard Time)
new TZDate(1732204800000, 'America/Denver').toString()
// Thu Nov 21 2024 09:00:00 GMT-0700 (Mountain Standard Time)
format(fromUnixTime(1732204800, { in: tz('America/Denver') }), 'MM/dd/yyyy h:mm a z')
// 11/21/2024 9:00 AM GMT-7
format(new TZDate(1732204800000, 'America/Denver'), 'MM/dd/yyyy h:mm a z')
// 11/21/2024 9:00 AM GMT-7

Are my expectations wrong? I would expect Chrome's output to match the node's output.
Thanks in advance for any hints 🙏🏻

Browser: Chrome, 5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Safari/537.36
Node: v23.1.0
date-fns: 4.1.0
@date-fns/tz: 1.2.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant