admin管理员组文章数量:1379238
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)
本文标签: javascriptHow to get timezone name list using dayJsStack Overflow
版权声明:本文标题:javascript - How to get timezone name list using dayJs - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744013069a2575924.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论