Get user timezone string with Javascript / PHP?

后端 未结 4 1376
猫巷女王i
猫巷女王i 2020-12-06 08:07

I\'m trying to get the user\'s timezone as a string on singup. example:

$timezone = \"Asia/Tel_Aviv\";

While researching the issue, I got

4条回答
  •  無奈伤痛
    2020-12-06 08:31

    1. You cannot get the timezone name from an offset. That's because there are many timezones which have the same offset at any given time, so you can't pick one based on an offset. (If you do, this will bite you in the butt later when the timezone goes into or out of DST, changing the offset.
    2. Your best bet is to do geolocation by IP address (google it, lots of material out there) as a best first guess and then give the user an option to choose his timezone himself.

提交回复
热议问题