marnusw / date-fns-tz

Complementary library for date-fns v2 adding IANA time zone support
MIT License
1.01k stars 112 forks source link

`utcToZonedTime` outputs a date in locale time #251

Closed jack-rouleau-poap closed 10 months ago

jack-rouleau-poap commented 10 months ago

Hi! We're trying to use this library to work with our dates and timezones information.

The client receives a Zulu datetime string and a timezone string. E.G.:

const date = '2023-08-31T14:30:00.000Z'
const timezone = 'Australia/Perth' // +8

When using utcToZonedTime with these values the output has the right date and time but the wrong timezone: Thu Aug 31 2023 22:30:00 GMT-0400 (Eastern Daylight Time)

With EST being the timezone in which I find myself.

Are we misunderstanding what the function should be doing? Documentation makes it sound like the output should be the appropriate date/time in the given timezone. The date and time are good but not in the given timezone.