Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

mapping location to a time zone

Tags:

timezone

maps

I need to get the time zone for a given address/location. Assume that the address/location can be reverse geocoded (using google) to a lat/lng if necessary.

This means that I may not have a zip code.

I was really hoping that google provided some kind of API for this, but it seems that they don't. At a minimum you can google search for "time in washington, dc" and get the time/TZ -- but then I'd have to screen scrape that which is not fun :(

I know there are databases available that map locations to time zones, but that'd have to be maintained. Has anyone come up with a tricky solution to this problem?

Thanks!

like image 612
jsharpe Avatar asked Apr 09 '26 10:04

jsharpe


2 Answers

Google provides an API for this.

https://maps.googleapis.com/maps/api/timezone/<json or xml>?location=<lat>,<lng>&timestamp=<unix timestamp>&sensor=<true or false>

eg:

https://maps.googleapis.com/maps/api/timezone/json?location=39.6034810,-119.6822510&timestamp=1331161200&sensor=false

like image 73
Dean Rather Avatar answered Apr 11 '26 14:04

Dean Rather


http://www.geonames.org/ provides an API that returns the timezone given a lat/lng

like image 23
jsharpe Avatar answered Apr 11 '26 12:04

jsharpe



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!