How to get timezone name list using dayJs
Asked Answered
H

2

6

I was recently using momentjs but just switched to dayjs. However, I need to get a list of timezones. With momentjs it was pretty simple : moment.tz().names() , but with dayjs I can't figure out how to do it. I don't want to get 500+ timezone, rather I need I shorter, more compact list that taking account winter/summer hours changes.

Any Idea ?

Hendrix answered 26/8, 2022 at 7:16 Comment(2)
This might give you some insight. github.com/iamkun/dayjs/issues/695Shied
Or just don't rely on a library https://mcmap.net/q/21144/-how-to-get-list-of-all-timezones-in-javascript/295783 Intl.supportedValuesOf('timeZone')Kerato
F
3

Use the code below in your browser console

 for (const timeZone of Intl.supportedValuesOf('timeZone')) {console.log(timeZone)}
Find answered 9/11, 2023 at 14:54 Comment(0)
H
0

You can use Intl.supportedValuesOf('timeZone'). This will return the name of the available time zones. This is not dayjs dependent. It can be used

let timezones = Intl.supportedValuesOf("timeZone");
console.log(timezones)
Hoang answered 9/11, 2023 at 15:46 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.