What browsers support timezone conversion automagic?

天大地大妈咪最大 提交于 2019-12-11 09:59:42

问题


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


回答1:


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.




回答2:


Supported in all browsers, except Chrome: http://www.w3schools.com/jsref/jsref_toLocaleString.asp



来源:https://stackoverflow.com/questions/5109586/what-browsers-support-timezone-conversion-automagic

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!