代码之家  ›  专栏  ›  技术社区  ›  theburningmonk

从IP地址查找时区

  •  3
  • theburningmonk  · 技术社区  · 16 年前

    当我拥有的只是他们的IP地址时,是否有方法找到用户所在的时区?我正在寻找需要应用到服务器时间的时间偏移,以便找到用户位置的时间。

    5 回复  |  直到 16 年前
        1
  •  9
  •   Community Mohan Dere    9 年前

    您需要尝试确定位置(这远不是100%准确)。看到了吗 this question 关于这样做。

    看到了吗 this question

    让客户端在连接时发送时区(或UTC偏移量)要可靠得多。

    one more question 关于使用JavaScript确定客户端时区。

        2
  •  1
  •   Francis    8 年前

    您可以使用 ipapi.co :

    https://ipapi.co/8.8.8.8/timezone
    > America/Los_Angeles
    
    https://ipapi.co/8.8.8.8/utc_offset
    > -0800
    
        4
  •  0
  •   Propeng    16 年前

    ip2nation提供了一个SQL数据库,您可以查询该数据库来地理定位IP地址:
    http://www.ip2nation.com/ip2nation/Download

    有了国家代码,您可以通过查询另一个数据库或库来检索一个国家的时区。

        5
  •  0
  •   Jonathan    8 年前

    restSharp.org 还有我的服务 ipdata.co

    var client = new RestClient("https://api.ipdata.co?api-key=test");
    var request = new RestRequest("1.1.1.1", Method.GET);
    request.AddHeader("Content-Type", "application/json");
    IRestResponse response = client.Execute(request);
    var content = response.Content; // raw content as string
    RestResponse<Ip> response2 = client.Execute<Ip>(request);
    var time_zone = response2.Data.time_zone;