如何获得客户的时区从他的IP地址的偏移量 [英] How to get clients timezone offset from his ip address

查看:226
本文介绍了如何获得客户的时区从他的IP地址的偏移量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要得到客户的时区从他的IP地址的偏移我的web应用程序。我一直在使用的Javascript功能getTimeZone获取试过,但是,一些客户有自己的时区或时间设置不正确。我想根据自己的时区,以获得偏移和渲染一些信息回客户端。

I want 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.

问候,
Vamyip

Regards, Vamyip

推荐答案

如果你可以调用Web服务,你可能想尝试ipinfodb.com。例如:

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&安培;时区=真

返回:

<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>

一个更快的选择是免费使用 的MaxMind GEOLITE上城市 。如果它不够好,你可以明显地升级到更准确的付费版本。我不能为付费版本的质量说话,因为我从来没有使用过。您可以下载文件的二进制数据版本同一个数据库中,然后使用的C#类来查询。

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.

这篇关于如何获得客户的时区从他的IP地址的偏移量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆