Get country from timezone
i have a news script
and it multi language ..
i want detect automaticlly the language of the visitor ...开发者_开发问答
i found more questions here about get the country from javascript timezone
them problem was because more citis is Similar time
" I DONT WANT DETECT COUNTRY " <- if that hard to get it !
only language !
so , what is the best way to get the visitor language or country by javascript ?
i don't understand javascript ever ! , and can't know what you can do by javascript
my two ideas is ..
first idea
get the time of visitor
example
EG = 0300
and in php i make an array contain ('0200'=>'Egypt') and another array ('Egypt'=>'AR')
second idea
in my clock time zone box , i see
Time Zone : Cairo <- egypt
can we get the name ?
Thank you !
You do not want to use time zones to determine language. People in the same time zone can speak different languages.
One alternative is to check the accept-language header.
For a similar discussion see: How do you detect a website visitor's country (Specifically, US or not)?
You can't get the country or language from the time zone offset.
For example, take UTC+1 in winter time. This could be France, Spain, Norway, Germany, Belgium, etc. They're all in Central European Time.
If you can get an Olsen name such as "Europe/France" or "Europe/Germany" that clearly gives you a lot more information, but you can't get that just from the offset from UTC.
Generally this can work, kinda.
But you would not get an specific location.
Especially in Europe and Africa there can be a lot of countries in one time zone and you couldnt differ between them.
I hope this helps
anmother way to do it ip location: http://www.geobytes.com/iplocator.htm?getlocation
http://jquery-howto.blogspot.com/2009/04/get-geographical-location-geolocation.html
from the ip you can find teh country and language would work for most countries except for canada etc...
精彩评论