PDA

View Full Version : Getting a time zone, or country even


who
6-20-05, 02:40 AM
I would like to know if there is any way to get a visitors country (or timezone) into a variable part of a php script. I have seen what "IP2Country" can do, but thats way to much for what I'm going after. Unless powweb could get like a "community database" which would be cool, but I don't think thats in the cards.

so far I have noticed Mozilla tacks some info into userstrings, like en-US for USA, and en-GB for England
so i've cooked this up if(eregi('en-US', $HTTP_USER_AGENT)) {$thistime = date("H")+1;}
if(eregi('en-GB', $HTTP_USER_AGENT)) {$thistime = date("H")+8;}
else {$thistime = date("H");}
echo'"'.$thistime.'" Is this close to your time?'; however it only works with Mozilla, it's a start I guess, unless there is any other way that somone knows of. Any ideas tips, ect. would be greatly appreciated!

RTH10260
6-20-05, 12:33 PM
so far I have noticed Mozilla tacks some info into userstrings, like en-US for USA, and en-GB for England
so i've cooked this up if(eregi('en-US', $HTTP_USER_AGENT)) {$thistime = date("H")+1;}
if(eregi('en-GB', $HTTP_USER_AGENT)) {$thistime = date("H")+8;}
else {$thistime = date("H");}
echo'"'.$thistime.'" Is this close to your time?'; however it only works with MozillaIt doesn't 'work only with Mozilla', it just depends how the user has his/her 'user agent' set up in the browser (it's neither guaranteed to be included).

The language shown is the setting of the GUI. For example, I am running an en-GB configured computer as my choice of English environment, although I live in the German speaking part of Switzerland. What time setting do I get during regular time zones and during summer saving times ? The UK can be one to two hours off my local time.

On the internet, don't try to outguess the user (even the IP number of large ISPs can only be a best guess like the head office's zone). Ask users what time zone they are residing in, then use it to make the offset with the available date/time functions.
Check again how it looks in your profile here in this forum ;)
____________________
If you don't mind some scripting, use Javascript and use the true settings of the client browser/computer.