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

Timezones always getting returned in my local time #295

Open
ttante opened this issue Aug 20, 2024 · 4 comments
Open

Timezones always getting returned in my local time #295

ttante opened this issue Aug 20, 2024 · 4 comments

Comments

@ttante
Copy link

ttante commented Aug 20, 2024

I've been using this module for months and recently updated to v3. Since then I can't seem to get a timestamp to show up in any other timezone.

If i provide a timestamp with the format of '2024-08-20T19:07:45.603000' and try to convert it it EST (using 'America/New_York')
I get something like this: "Tue Aug 20 2024 19:07:45 GMT-0500 (Central Daylight Time)}".

I have tried toZonedTime, fromZonedTime, and format and all solo and in combination with an initial conversion to UTC & gathering the offset and subtracting the offset in milliseconds. No matter what I end up with my local time at the end.

Running new Date('2024-08-20T19:07:45.603000') coerces the timezone into my local time on a browser, but not in node. I don't know if this is a new update to the Date initializer, but the result is that I can't get my times to be recognized in the correct timezone (they actually are in 'America/New_York' time).

I suspect this issue may be due to the use of new Date() in the date-fns-tz library. At this point I've had to look into Luxon and other libraries for this, but I was really enjoying the module and I'm really confused as to why this is happening.

@yepMad
Copy link

yepMad commented Aug 28, 2024

Same

@MarcosEscobarR
Copy link

same

@kossnocorp
Copy link

Node.js and browser parse date strings consistently (albeit confusing).

Node.js:

image

Browser:

image

You might want to use parseISO for such strings:

image

@ggPeti
Copy link

ggPeti commented Sep 25, 2024

image

might be related

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

5 participants