简体   繁体   中英

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

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" .

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 resolved.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM