使用Moment-Zone库的Zone缩写是动态的吗 [英] Is Zone abbreviation using moment-zone library a dynamic

查看:128
本文介绍了使用Moment-Zone库的Zone缩写是动态的吗的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用矩时区库来显示时间戳记之后的区域缩写。
我正在使用以下代码段显示美国纽约的区域缩写

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();

这将向我返回区域缩写 EDT
我的问题是:冬天到来时会自动返回 EST 吗?

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

推荐答案

是的。

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

来源

这篇关于使用Moment-Zone库的Zone缩写是动态的吗的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆