Is there a library that allows one to get the timezone from city+zipcode combo?

I need to translate a time that I have in a known timezone to a time in a location for which I know the city and zipcode.

Is there a library that already does this?
If not is there a free online service/API that could be used to solve this?
If not, how do you suggest to approach this task?

The cities are all in USA but I don’t live in USA. Maybe there is some official database that I can use.


I ended up using the Google Maps API and having a field for user to search for their City. I then extracted the timezone and other location data I needed.

I could not find a reliable alternative.

If this is an option let me know and I can post some code (However it is just javascript on the client as per the docs).


PS: not free but low cost


You can use GeoNames to fetch position from the zip code, however I wouldn’t rely on that too much, because people can use different TZ than their “local” one (for example they are dealing with customers in different TZ, and it is easier for them to use TZ of the client). So I would rather ask - what for you need that?


I have found this data (which I use in my project) to be accurate and relatively low cost:

Google maps API could work but check the cost/TOS restrictions.

1 Like

It is exactly one of these solutions that we’re implementing. Our app should display the time in the TZ of the client.

Thank you all for the suggestions. I will propose these solutions to my contact.

1 Like

The tz_world packages translates a geo point (a location with a lat, lng) into a timezone using map data from osm and timezone data from iana. So if you can translate a place into a location (with geonames for example), then tz_world will give you the timezone name. Its very cool.

Note that tz_data on hex requires ecto and postgres with postgis, but the master branch on GitHub does not and the author has indicated he will publish that version to hex this week.


This is very useful information. I already have tz_world installed as a dependency of timex. has an API: (not free). Their main timezone page allows you to lookup by name or just zipcode so I would assume their API would too.

No affiliation - just used their meeting planner a lot in a previous life.

I don’t know how up-to-date this is but I found this free data including zips, timezones, and lat/long: Note the city name here is the “primary city name” of the given zip which is probably not good enough as multiple cities/town names can exist in a given zip.

Zips do change over time so the inexpensive (non-free) resource I sent over the other day updates changes from the authoritative USPS monthly if needed and does include all the “alternate” city names per zip.

Finally, for the purpose of city/town/hamlet name to lat/long (if using tz_world solution to get timezone) nothing beats the free USGS GNIS data:

1 Like