Is Zone abbreviation using moment-zone library a dynamic
Asked Answered
H

1

1

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?

Hyperostosis answered 8/7, 2020 at 15:58 Comment(0)
U
0

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

Unsearchable answered 8/7, 2020 at 17:54 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.