Fog Creek Software
Discussion Board

Time Zone lookup via XML


I was using the information at this site: to be able to do a lookup by city and get its latitude, longitude, and time zone. (It queries a weather website which returns the weather data along with the location's coordinates in XML format.)

Unfortunately, the time zone data leaves much to be desired. In some cases it is off by an hour (regardless of daylight savings or not), in others it is difficult to determine whether there is daylight savings at all for the location.

So, does anyone know of some method of determining the time zone via the latitude and longitude alone? Or, does anyone know of some other data source that can return correct time zones for a location?

Avrom Finkelstein
Tuesday, July 29, 2003

I don't know a precise answer to your question, but rather some basic information: time zones boundries are often political in nature, so you need to find someone (and I don't know who) with a proper, up-to-date database of time zone boundries. I rather assume that doesn't change very often, but given that politics are involved, don't make bets on how often changes might occur.

Also, be aware that in some places daylight savings time does NOT follow a regular scedule, but is implemented each year at the whim of a political body. So expect to have issues in dealing with DST.

Good luck!

Michael Kohne
Tuesday, July 29, 2003


Thanks. I am aware of the problems regarding Time Zone standards (basically, there *are* no standards). I am prepared to allow for a few discrepancies to arise due to political changes.

What I was looking for was something that returned the standard "area/city" format (e.g. "Americas/New_York") or the standard three character format (e.g. "EST"). That way, I can use it with the Java TimeZone class which automatically adjusts for DST where applicable. (And, yes, it will have problems where DST is politically determined and thus could vary year by year.)

Just for the record, I wish to use the lat/long/timezone so I can calculate sunset times for the given location.

Avrom Finkelstein
Tuesday, July 29, 2003

they sell some sort of database with timezone info.

Steve H
Tuesday, July 29, 2003

They are selling it for $400. I'm looking for something for free, if possible.

Avrom Finkelstein
Tuesday, July 29, 2003

I've never used this before, but might work:

Since you know the city, you could query by that I guess.

Tuesday, July 29, 2003 has sunset/sunrise info for U.S. and worldwide locations and claims to handle DST at least within the U.S.

John C.
Tuesday, July 29, 2003

look up 'zoneinfo' or 'tzone'. i think the data itself is on  and is kept up to date. it also goes back in time many years, so you can find out what the offset was for may 5, 1923 in Caracas, or other such random things.

it's actually hard to find out info on it...

Tuesday, July 29, 2003

check out

Matthew Lock
Wednesday, July 30, 2003


I need something that does time zone lookup (or calculations) worldwide, not just the US.

John C.,

I don't need a web interface where I can lookup sunset times. I need lat/long/time zone info so I can calculate it myself.


I was looking into that the other day. I'm not sure whether they have time zone information for *every* location or just for cities that are part of the standard "area/city" time zones. For example, "America/New_York" is defined as UTC -5 with DST. But Toronto (where I live) doesn't have its own code (but could use "America/New_York" as its code as we are in the same zone).
I'll have to look into it more.


XMethods only has time zone lookup for US zip codes. I need worldwide.

Avrom Finkelstein
Wednesday, July 30, 2003

They should have info for every timezone. So if America/New York and America/Toronto are different (say the daylight savings rules are different), there should be a place for each. There can also be aliases, so some systems allow USA/Eastern to map to America/New York.

The hard part is mapping the user to the right timezone. A worldwide map of latitude/longitude is difficult; you may notice that Windows solves this by scrolling a world map but not displaying any boundaries (at one time they displayed boundaries.) The Mac used to have a map with timezone info, OSX at least partly uses the zoneinfo database

I started to look into this for a project last year, but never got to the point of needing to use it, so I'm far from an expert.

Wednesday, July 30, 2003

Well, I'll have to look into it.

What I wonder though is if it would work for every little place on the planet. If one looks up some Hicksville, will it have its correct time zone?

I don't want to mess around with having users choose the time zone themselves. I just want it to be be simple: Enter a location, it does a lookup, and gets sunset times.

I found a web service that returns lat/long for any world location. Take a look at and go to Samples->Sample Clients->Place Finder Sample.

Avrom Finkelstein
Wednesday, July 30, 2003

*  Recent Topics

*  Fog Creek Home