Invalid time zone specified: US/Alaska, US/Arizona, US/Mountain, US/Central etc error in Chrome but working in Mozilla

前端 未结 1 517
天涯浪人
天涯浪人 2021-01-20 21:34

I am trying to convert timestamp in to various time zone\'s local time and found certain TimeZone are not supporting in Chrome (v76.0.38) but working fine in Mozilla (v68.0.

1条回答
  •  醉话见心
    2021-01-20 22:22

    That page describes timezones supported by another google product, not Chrome.

    Referring to MDN's documentation on toLocaleString:

    timeZone
    The time zone to use. The only value implementations must recognize is "UTC"; the default is the runtime's default time zone. Implementations may also recognize the time zone names of the IANA time zone database, such as "Asia/Shanghai", "Asia/Kolkata", "America/New_York".

    Valid time zones can be found at that IANA link, or you can use Wikipedia: List of tz database time zones. You'll notice that all of the "US/*" timezones are deprecated. Use only Canonical entries from the Wikipedia page, such as:

    • America/New_York
    • America/Denver
    • America/Chicago

    etc.

    0 讨论(0)
提交回复
热议问题