2

is there anyway I could figure out an estimated (Olson) ZoneInfo value (eg. ("America/Los Angeles", "Europe/London", etc.), for a single public IP address ... in .NET?

I already have a full list of ZoneInfo values, so that's not a problem ... and in a drop down box. I just want to default a selected value based on an IP.

I understand the IP won't be 100% accurate and proxies could frak things ... but this is to get a rough value.

Is this possible?

I was thinking it might be possible to associate a ZoneInfo value to a GMT timezone .. maybe?

And yeah .. for .NET please.

cheers!

(thanks OpenID for using ZoneInfo instead of GMT timezones :( )

Update

I found this page which describes the relationship between a Zone and Lat/Long. Is it therefore possible (eg. anyone want to suggest some code examples?) how, using a Lat Long, determine the correct ZoneInfo?

Community
  • 1
  • 1
Pure.Krome
  • 84,693
  • 113
  • 396
  • 647
  • with my code you get the 2 letter country from the IP, then get the TimeZone using that Table (the TimeZone List from Wikipedia)... that will do the trick no? – balexandre May 06 '09 at 11:14
  • So, with if the IP x.y.z.a == CountryCode 'US' ... which TimeZone does that refer to, in the list of timezones in America/XXXX ?? – Pure.Krome May 06 '09 at 11:31
  • updated my answer with a new answer :) – balexandre May 06 '09 at 22:19

2 Answers2

1

That is call Geolocalization and they are several products around. Mostly this is a paid service.

You can try this one... its free. :)

Lucas
  • 339
  • 1
  • 4
  • Nice link and db :) but ... it's not giving me any ZoneInfo information. So i get a Lat/Long. Can i convert that into a ZoneInfo? – Pure.Krome May 06 '09 at 05:39
  • Im not sure what you meen by "ZoneInfo".... This is what that webservice realy outputs: http://iplocationtools.com/ip_location_api.php If that doesnt help I think you'll gonna have to customize the db... Again, there are several paid products. For that you better consult your ISP. – Lucas May 06 '09 at 10:24
  • If you're not sure what ZoneInfo is, then you might not understand the question properly. As such, I've updated the initial post btw. – Pure.Krome May 06 '09 at 11:09
  • I see. Oslon has a dll that you can install inside the .net gac. Here is some info: http://www.codeproject.com/KB/dotnet/Using_time_zones_in_NET.aspx – Lucas May 06 '09 at 12:52
1

I created my own service to give me the ISP and Country from an IP

you can try it here

I can share the code, if this is what you want.


New answer

Why do you want the TimeZone from an IP Address? Why do you need the IP Address for? You can easyly get the OffSet time from the client.

I just implemented the code and it outputs the correct GMT timezone.

balexandre
  • 73,608
  • 45
  • 233
  • 342
  • ooo! interesting. Bummer that i'm behind a proxy .. not sure if that's sending my LAN Ip (10.0.1.x) I'll try at home where my ip is not getting fraked. – Pure.Krome May 06 '09 at 05:37
  • It's only the way I get the IP... you can see the ServerVariables object if you go to http://www.balexandre.com/sessions.aspx you will have the different IP's there... try it. – balexandre May 06 '09 at 07:19
  • Because i'm using OpenId and they have tz/Olsen times as their timezone implimentation. Now, if the user hasn't provided that, I wish to auto-select the closest timezone to the current connection ... which is why i'm guessing i need to do this via IP Address. – Pure.Krome May 06 '09 at 23:21
  • but as you can see from my code, your guess is wrong, you should get their local time and use the Offset to get the timeZone, with that conversion list in a XML, for example, you can get what you need to implement. I wonder why do you need the dropdown, should't be easy to login just like StackOverflow does? just the openID and that's it? Are you using the OpenID Library for .NET: http://wiki.openid.net/Libraries called DotNetOpenID @ http://dotnetopenid.googlecode.com/ ? – balexandre May 07 '09 at 06:06