user3080347
user3080347

Reputation: 23

Getting short timezone abbreviation in JavaScript

I have string representing datetime and time zone (IANA) on client side.

How do I get abbreviation for it (like EST/EDT)?

Upvotes: 2

Views: 2061

Answers (1)

Eugene Loy
Eugene Loy

Reputation: 12416

To do this you can use timezone-js.

Once you set it up (you'll need fresh version of IANA/Olson timezone database, see docs) you can use it to get abbreviation for given datetime and timezone:

var dt = new timezoneJS.Date('10/31/2008', 'America/New_York');
var abbreviation = dt.getTimezoneAbbreviation();

... (abbreviation will be equal to "EDT")

Upvotes: 2

Related Questions