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

How do I create a date in a specific timezone? #36

Open
chalupagrande opened this issue Jan 8, 2025 · 2 comments
Open

How do I create a date in a specific timezone? #36

chalupagrande opened this issue Jan 8, 2025 · 2 comments

Comments

@chalupagrande
Copy link

I have a date like: 2025-01-08T18:00

How do I tell date-fns that this is in America/Chicago timezone?

@jawnothin
Copy link

I came here to get the answer to that specific question... because right now it just assumes the timezone on the local device, which may or may not be correct.

@cbejensen
Copy link

cbejensen commented Jan 9, 2025

Seems like TZDate reads ISO-like strings as UTC or local, while passing in the elements as individual args achieves the desired result:

console.log(new TZDate(2025, 0, 8, 18, 'America/Chicago').toString());
// Wed Jan 08 2025 18:00:00 GMT-0600 (Central Standard Time)

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

3 participants