1

Running the following code in Javascript: var d = Date.UTC("Wed Jan 30 16:27:50 IST 2002");

Results in d being a NaN, same goes for using ICT (Indochina time) instead of IST (Israel Standard Time), although both seem to be valid time zone abbreviations. When I use EST instead, I get a Date object as expected.

Does any workaround exist? I can replace IST with UTC+2, but I don't want to manually match any not supported time zone, especially since I don't know what time zones are supported and which are not...

0

1 Answer 1

2

Don't use time zone abbr. See RFC 2822, which Date uses for the string format, https://www.rfc-editor.org/rfc/rfc2822#page-14 It just does not know all but a selected few of those timezone abbreviations and relies on numeric offsets to GMT.

Or, just one example of many pages you can find by asking almighty Google, http://corneliusweiss.de/2008/10/14/dealing-with-time-zones-in-javascript/

Sign up to request clarification or add additional context in comments.

3 Comments

Problem is that I get the zone abbr. from another application, have no control over this...
You can create your own hash table and convert those strings: timeanddate.com/library/abbreviations/timezones
@Iribinik - Time zone abbreviations are ambiguous. For example, there are 5 different timezones abbreviated by EST. Look at the list on the link Morre provided for more examples. If all you get out of the other application is the abbreviation, then you do not have enough data to determine which timezone it is. You would have to know something else - like what time zones are relevant for your users.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.