【发布时间】:2020-03-19 01:09:12
【问题描述】:
MomentJS 提供了一系列开箱即用的强大功能。
通过timezone 插件的其中一个是显示时区的字符串缩写,例如CET:
const locationName = moment.tz.guess(true) // "Europe/Berlin"
const timezoneInitials = moment.tz(locationName).format('zz') // "CET"
是否可以从时刻对象中获取 CET 的完整时区名称字符串(即Central European Time)?
如果没有,有什么替代方案?
截至今天,此类解析不可用/记录在案。从List of time zone abbreviations 之类的列表中映射和重复数据删除似乎也不是最优的。
【问题讨论】:
-
我不这么认为,因为他们建议您可以通过自己覆盖
zoneName方法来做到这一点,momentjs.com/timezone/docs/#/using-timezones/formatting
标签: javascript typescript timezone momentjs