date-fns utcToZonedTime has unexpected output

3k Views Asked by At

According to date-fns docs, utcToZonedTime could be used to get zoned time from utc, but I can't make it to work (and I find it hard to believe they have such a basic bug):

console.log(dateFnsTz.zonedTimeToUtc("2021-05-08T02:00:00.000", "America/Denver"))
console.log(dateFnsTz.utcToZonedTime("2021-05-08T08:00:00.000Z", "America/Denver"))

The [unexpected] output:

2021-05-08T08:00:00.000Z
2021-05-08T00:00:00.000Z
0

There are 0 best solutions below