时刻时区.js允许我传递时区缩写并获取转换后的日期/时间

Will moment-timezone.js allow me to pass the timezone abbreviation in and get the converted date/time

本文关键字:时区 转换 时间 获取 日期 允许我 js 缩写 时刻      更新时间:2023-09-26

我正在研究一个将在国际上使用的日历解决方案。在我的数据中,我有时区缩写(CET,EST,JST)。是否可以将此缩写传递到时刻时区.js以便从 EST 进行时间和日期转换,这是数据提供程序的默认

No. 这是一项不可能完成的任务,因为时区缩写不一致且模棱两可。例如,CST 可能是美国或澳大利亚的中部标准时间。 或者可能是中国标准时间或古巴标准时间。

通常,仅使用时区缩写进行显示。 不要将它们解析为输入。

从文档(http://momentjs.com/docs/#/parsing/utc/)我知道您可以使用UTC:

moment.utc();
moment.utc(Number);
moment.utc(Number[]);
moment.utc(String);
moment.utc(String, String);
moment.utc(String, String[]);
moment.utc(String, String, String);
moment.utc(Moment);
moment.utc(Date);

至于CET,EST和JST,我不确定,但您可以根据与UTC的偏差来计算它们。例如,从 CET 到 UTC 有直接对应关系,如您在此在线转换器中看到的那样:

  • http://www.worldtimebuddy.com/cet-to-utc-converter

希望对您有所帮助!