简体   繁体   中英

IP to location + local time?

Currently I've been using http://www.geoiptool.com/ but I can't get the local time. I don't know what to do to get the local time.

Can someone help me out, to display location + local time? I have a mail app and I try to display IP in location + local time.

Geobytes will give you the offset:

http://www.geobytes.com/IpLocator.htm?GetLocation&IpAddress=64.34.119.12

Or in an XML format (you might need to view source to see it):

http://www.geobytes.com/IpLocator.htm?GetLocation&template=php3.txt&IpAddress=64.34.119.12

This will give you the offset, just add/subtract the offset to GMT/UTC.

Well, this is not real answer to your question but can help you to properly understand how inaccurate this method is.

Please, read this answer as a side note.

Yes, it's OK to offer or set location/time for your users. But you should provide country/time selector for them also. Some of IP's can not be resolved properly (anonymous proxy, borrowed IPs from other countries (my case), continental IPs (like group "Europe", "Asia", etc), etc.

My case shows how this approach may be wrong.

When I've tried ipLocator from geobytes.com I've got this:

在此处输入图像描述

My IP address has been resolved to:

  • Location: Romania
  • Time offset: +0200 (at the moment DST is active so it's +0300 )

Real problem is that my location is not Romania , and my time offset is +0100/+0200 .

Look this picture:

在此处输入图像描述

Red arrow shows my real location. Info in black box shows correct values for my real location. Well, wrong location is not such a big problem for users, but wrong local time is very annoying thing.

Yes, I know, that's not what you're looking for. But you should not fix users location and/or local time because it can be wrong approach. IPv4 address is certainly not something accurate to get real info about user.

Also, I found that ipLocator doesn't follow DST rules and using that time offset (image #1) will show wrong local time during Summer (for countries/regions/provinces which consider DST).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM