What browsers support timezone conversion automagic?
This example should display "Mon Dec 25 1995 07:30:00 GMT-0600 (CST)" if you're on a -6 time:
(new Date('Mon, 25 Dec 1995 13:30:00 GMT'))
or js fiddle: http://jsfiddle.net/nFADG/
Is this sort of conversion supported in IE and older Firefoxes?
For all the crazy methods that a google search offers to convert timezones in js one might start thinking there's something wrong with this one.
Edit: removed the toLocaleString() to avoid confusion.
Edit: changed the date string to reflect the IETF standard since it actually wasn't parsing properly in FF. https:/开发者_开发技巧/developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Date/parse
I would think that all browsers in themselves support the conversion. However the underlying OS is just as important, if you are on a machine with un-updated or incomplete zoneinfo files you will have problems in certain edge cases. The browser will base its conversion on information in the OS.
When working with timezone detection I've come across several such cases, and I've not really come up with a solution. Except to hope that most of your users are not in say... Gaza, on say... Windows XP without even service pack 1.
Supported in all browsers, except Chrome: http://www.w3schools.com/jsref/jsref_toLocaleString.asp
精彩评论