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 pact list that taking account winter/summer hours changes.
Any Idea ?
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 pact list that taking account winter/summer hours changes.
Any Idea ?
Share Improve this question asked Aug 26, 2022 at 7:16 JohnJohn 3372 gold badges6 silver badges14 bronze badges 2- This might give you some insight. github./iamkun/dayjs/issues/695 – nad Commented Aug 26, 2022 at 7:19
-
1
Or just don't rely on a library stackoverflow./q/38399465/295783
Intl.supportedValuesOf('timeZone')
– mplungjan Commented Aug 26, 2022 at 7:20
2 Answers
Reset to default 3Use the code below in your browser console
for (const timeZone of Intl.supportedValuesOf('timeZone')) {console.log(timeZone)}
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)