最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How to get timezone name list using dayJs - Stack Overflow

programmeradmin5浏览0评论

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
Add a ment  | 

2 Answers 2

Reset to default 3

Use 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)

发布评论

评论列表(0)

  1. 暂无评论