"Invalid time zone specified" with date-fns-tz in React Native

910 Views Asked by At

I have an Expo project and use date-fns and date-fns-tz to manipulate time and timezones.

Regarless of the timezone I use (Europe/Paris, UTC, America/New_York'...), I get the following error:

Invalid time zone specified: Europe/Paris

I've tried to copy/paste the example from the documentation, but same thing.

Here is a code snippet:

import { formatDuration, intervalToDuration, parseISO } from "date-fns";
import { formatInTimeZone} from "date-fns-tz";
formatInTimeZone(
      date,
      "Europe/Paris",
      "yyyy-MM-dd HH:mm:ssXXX"
    );

I've tried the solution described here but my app gets errors.

Using "date-fns": "^2.16.1" and "date-fns-tz": "^1.3.7".

1

There are 1 best solutions below

1
On

i had the same problem with react-native(CLI) and doesn`t achieved to resolve the problem. I saw something about a version of hermes, I think in react-native 0.59 or higher this is solved.