Scott Stewart
Scott Stewart

Reputation: 55

Will moment-timezone.js allow me to pass the timezone abbreviation in and get the converted date/time

I'm working on a calendar solution that will be used internationally. In my data I have the timezone abbreviation (CET, EST, JST). Can this abbreviation be passed in to moment-timezone.js to do the time and date conversions from EST, which is what the data provider defaults to?

Upvotes: 0

Views: 469

Answers (2)

Matt Johnson-Pint
Matt Johnson-Pint

Reputation: 241525

No. This is an impossible task, because time zone abbreviations are inconsistent and ambiguous. For example, CST could be Central Standard Time in the US, or in Australia. Or it could be China Standard Time or Cuba Standard Time.

In general, use time zone abbreviations for display only. Do not parse them as input.

Upvotes: 2

Flame_Phoenix
Flame_Phoenix

Reputation: 17574

From the documentation(http://momentjs.com/docs/#/parsing/utc/) I know you can use UTC:

moment.utc();
moment.utc(Number);
moment.utc(Number[]);
moment.utc(String);
moment.utc(String, String);
moment.utc(String, String[]);
moment.utc(String, String, String);
moment.utc(Moment);
moment.utc(Date);

As for CET, EST and JST I am not sure, but you can calculate those based on deviations from the UTC. For example, there is a direct correspondence from CET to UTC, as you can see in this online converter:

Hope it helps!

Upvotes: -1

Related Questions