Getting Olson timezone ID information from browser via javascript [duplicate]

谁说我不能喝 提交于 2019-12-10 17:31:30

问题


Possible Duplicate:
Javascript/PHP and timezones

It is possible to get the Olson timezone id from javascript on the client's machine e.g. (America/New York). I know that PHP can do this via the timezone object, something like this. $timezone->getLocation(); Does similar functionality exist for JS?

I know that you can grab the timezone offset of the client as followed: var curdate = new Date(); var offset = curdate.getTimeZoneOffset();

But I need more granular information provided by the Olson Id. Thank you for your help.


回答1:


You can't directly access timezone in JavaScript. You can, however, measure offsets reported at several different specific dates to deduce what exactly time zone is in use by comparing regular and daylight savings times to database of zones. There's a jsTimezoneDetect library that can do most of this work for you.



来源:https://stackoverflow.com/questions/10416552/getting-olson-timezone-id-information-from-browser-via-javascript

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