开发者

How to get clients timezone offset from his ip address

I wa开发者_开发知识库nt to get clients Time Zone offset from his IP address for my web app. I have tried using Javascripts getTimezone function, but, some clients have their timezone or time set incorrectly. I want to get the offset and render some information back on client based on their timezone.

Thanks for taking time to read the question. I am open for alternate approaches too.

Regards, Vamyip


If you can call a web service, you might like to try ipinfodb.com. For example:

http://ipinfodb.com/ip_query.php?ip=69.59.196.211&timezone=true

returns:

<Response> <Ip>69.59.196.211</Ip> <Status>OK</Status> <CountryCode>US</CountryCode> <CountryName>United States</CountryName> <RegionCode>41</RegionCode> <RegionName>Oregon</RegionName> <City>Corvallis</City> <ZipPostalCode>97333</ZipPostalCode> <Latitude>44.4698</Latitude> <Longitude>-123.343</Longitude> <TimezoneName>America/Los_Angeles</TimezoneName> <Gmtoffset>-25200</Gmtoffset> <Isdst>1</Isdst> </Response>

A faster option is to use the free MaxMind Geolite city. If it is not good enough, you can apparently upgrade to a more accurate paid-version. I can't speak for the quality of the paid version, as I have never used it. You can download the file binary blob version of the same database, and then use the C# class to query it.


google 'geolocation ip'

There are API's you can call provided by companies. Some are free, some are not.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜