【问题标题】:How to get all available time zones in Moment Timezone?如何在 Moment Timezone 中获取所有可用时区?
【发布时间】:2017-07-05 15:28:21
【问题描述】:

我想获取所有可用时区名称的列表,我为此使用了moment.tz.names 函数,如您所见:

import moment from "moment";
import "moment-timezone";

public availableTimeZones = moment.tz.names();

但我得到空值。我使用TypeScript + Aurelia + Webstorm开发程序,我安装了“moment-timezone”和“moment”:

npm install --save moment
typings install dt~moment --global --save
npm install --save moment-timezone
typings install dt~moment-timezone --global --save

实际上,我必须通过 moment.tz.add 添加所有可用时区。 我想拥有所有可用的时区。我不想添加一些区域然后使用它们。 你能帮帮我吗?

【问题讨论】:

  • 也许stackoverflow.com/questions/39452470/… 可以提供帮助
  • 我想要所有可用的时区。我不想添加一些区域然后使用它们。
  • 您需要在项目中包含 moment-timezone-with-data.js。见momentjs.com/timezone。单击文件以查看其内容。 moment-timezone.js 不包含时区列表。
  • 所以也许应该用列表导入文件。例如import "moment-timezone-with-data";
  • @Benny 确实,该帖子中的链接提供了所有时区的可下载集合。

标签: timezone momentjs aurelia typescript-typings


【解决方案1】:

import "moment-timezone-with-data" 是解决方案。

【讨论】:

    猜你喜欢
    • 2017-03-17
    • 1970-01-01
    • 2016-12-06
    • 1970-01-01
    • 2019-10-24
    • 2014-08-15
    • 1970-01-01
    • 2016-07-17
    相关资源
    最近更新 更多