如何使用moment.js库获取时区列表? [英] How do I get timezones list using moment.js library?
问题描述
我需要进行< select>所有实际世界时区的列表.如何获取带有时区列表的数组?
I need to make a <select> list of all actual world timezones. How do I get an array with timezones list?
推荐答案
对于时区,您应该手动添加自己制作的时区JS文件.
For timezone, you should manually add timezone JS file made by yourself.
在此页面中,您可以选择区域并生成一个文件,然后将其加载首先加载moment.js
.
In this page, you can pick the zones up and generate a file to be loaded after you load moment.js
first off.
您应该有类似的东西,看看:
You should have something like this, take a look:
<script src="/javascripts/modules/moment/moment-with-langs.min.js"></script>
<script src="/javascripts/modules/moment/moment-timezone.min.js"></script>
<script src="/javascripts/modules/moment/moment-timezone-data.js"></script>
JS moment-timezone-data.js
是时区的自定义列表.
The JS moment-timezone-data.js
is the custom list of the timezones.
但是,到目前为止,我知道,MomentJS 不会为您返回所有时区的列表,因为时区也可以更改.如果您需要填充select
标记,建议您从上面的链接中手动解析时区列表.
However, so far I know, MomentJS does not return for you a list of all timezones, because timezone can be changed as well. If you need to populate a select
tag, I suggest you parse the timezone list manually from the link above.
这篇关于如何使用moment.js库获取时区列表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!