Reputation: 8077
I need to create a select with the following values,
Eastern Standard Time (EST, GMT-5:00)
Central Standard Time (CST, GMT-6:00)
Mountain Standard Time (MST,GMT-7:00)
Phoenix Standard Time (PNT, GMT-7:00)
Pacific Standard Time (PST, GMT-8:00)
is there a way to do it through moment.js ?
Upvotes: 7
Views: 8979
Reputation: 1991
moment.js
has timezone support via moment-timezone, so if you load the full set of timezones, you can filter for the time zones you care about by iterating through moment.tz.names()
, and then calling format("z, Z")
to get the string you want.
> moment.tz("America/Los_Angeles").format("z, Z")
"PDT, -07:00"
> moment.tz("2016-01-01", "America/Los_Angeles").format("z, Z")
"PST, -08:00"
Upvotes: 12