2

I know that I can display time for a particular location using only JavaScript (and no web service or external data source), but... I want to avoid using this solution because I don't want to have to account for daylight savings time, and any other factors that make it complicated.

I'm looking for an easier way to display the time and always for a particular city (or zip code, or whatever identifier works...).

For example, I want a page to always say:

The current time in Miami is "X"

(where "X" should be replaced by the current time in Miami)

Is there a web service (or any other method) where I can post some identifier (city name, zip code, etc) and get back the time?

edt
  • 22,010
  • 30
  • 83
  • 118
  • possible duplicate of [Timezone conversion in php](http://stackoverflow.com/questions/2505681/timezone-conversion-in-php) – kennytm Jul 17 '10 at 19:02
  • I don't think this is a duplicate: The point here is to find out the time zone of a given location. – Pekka Jul 17 '10 at 19:03

1 Answers1

2

Is there a web service (or any other method) where I can post some identifier (city name, zip code, etc) and get back the time?

I don't know of a single web service that will do the job.

Google's Geocoding API can help. You can feed it a parameter, and it will return certain information, such as the latitude/longitude. Example using a zip code, but I'm sure you can easily put in a city/state pair and make it work.

You can then take that lat/long pair and point it at service like GeoNames. They have a timezone API that takes a lat/long pair and returns quite a bit of information. Example using the lat/long from the zip code.

Charles
  • 50,943
  • 13
  • 104
  • 142