Welcome Guest, Not a member yet? Register   Sign In
getting a user / visitor timezone?
#1

[eluser]edwardmolasses[/eluser]
hi there,

I couldn't find this in search even though i'm sure it must have been asked at some point, but anyways, what method would you use to get the timezone of a non-member visitor to your site? I would prefer to use php rather than javascript, but i suppose javascript would have to do if there aren't any other solutions. Any help would be much appreciated!

thanks,
andrew.
#2

[eluser]coolfactor[/eluser]
Javascript runs in the browser that the visitor is using, so the browser would be in the same timezone as the user. PHP runs on the server, which could be anywhere else in the world.

This page has a good explanation and possible solution:
http://www.desisoftsystems.com/white-pap...lculation/
#3

[eluser]coolfactor[/eluser]
CodeIgniter's Timezone information doesn't seem to take into consideration Daylight Savings Time differences. For example, it's showing my UTC offset as -800 hours, when it's actually just -700 hours right now (I believe). I'm still wrapping my mind around date/time/zone concepts and trying to build a solid api into my customized CI libraries so I don't need to worry about date and time functionality anymore. It's been 3 years coming and time to get it together.

I have yet to search all of the forum posts, but if anyone has any working solutions, or further information about CI's implementation, I'd appreciate it very much. Thanks.
#4

[eluser]TheFuzzy0ne[/eluser]
I don't think it's possible to do 100% efficiently.

Using the JavaScript method, obviously the user must have JavaScript enabled, making it only partially effective.

I believe it can be done with PHP by doing something with the user's IP address, which will allow it to be traced back to it's geographical location. But again, if the user is using a proxy, and it's not close to them, then you can't

Basically, the most effective way to find out a user's timezone, is to just ask them. Of course, even that has it's flaws...




Theme © iAndrew 2016 - Forum software by © MyBB