Is Zone abbreviation using moment-zone library a dynamic

依然范特西╮ 提交于 2020-07-10 03:37:25

问题


I am using moment timezone library to show the zone abbreviation after the timestamp. I am using the following snippet to show the zone abbreviation of New York, USA

 var timeZone = moment.tz.guess();
    const zoneName = moment.tz(timeZone).zoneName();
    return moment().tz("America/New_York").zoneName();

This returns me the Zone abbreviation EDT. My question is: when winter will come will it automatically return EST?


回答1:


Yes, it will.

var jun = moment("2014-06-01T12:00:00Z");
var dec = moment("2014-12-01T12:00:00Z");

jun.tz('America/New_York').format('ha z');     // 8am EDT
dec.tz('America/New_York').format('ha z');     // 7am EST

Source



来源:https://stackoverflow.com/questions/62798753/is-zone-abbreviation-using-moment-zone-library-a-dynamic

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!