问题
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