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).
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?
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.
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.