Take the 2-minute tour ×

I am using this question (yahoo-weather-api-woeid-retrieval) to convert a US ZIP to a Yahoo WOEID value. However while the Yahoo reply returns all sorts of interesting stuff, what I am interested in getting is the correct timezone of the location.

Is there any easy way to return the timezone from Yahoo, or map a WOEID (or ZIP in that matter) to a timezone value?

As a fall back if I get a weather forecast of a US WOEID, that data includes the local time with timezone at the time of the forecast (ie it returns EDT, PDT HST etc). So I can scrape the data from there, but I would prefer to associate it more with the location data. An example of this is:

<yweather:condition  text="Cloudy"  code="26"  temp="72"  date="Tue, 26 Oct 2010 11:03 am EDT" />
share|improve this question

2 Answers 2

This question could help you getting the timezone for a zipcode. This answer might also help.

share|improve this answer
I have seen those questions before but I am specifically looking for a Yahoo API based solution. I know that Yahoo knows what I want to know. –  Peter M Nov 1 '10 at 22:07

I don't believe the functionality you want is exposed. The examples I've seen do something like this (PHP):

 * This function find the local date and time of any place using the geoname web service 
 * @example getTime(47.608,-104.231); //time of Machu Pichu
 * @param float $lat
 * @param float $lng
 * @return string local date and time in 24 hour format
function getTime($lat, $lng)
    $url = "http://ws.geonames.org/timezone?lat={$lat}&lng={$lng}";
    $timedata = file_get_contents($url);
    $sxml = simplexml_load_string($timedata);
    return $sxml->timezone->time;

Source: http://www.phpclasses.org/browse/file/22382.html (Free registration req'd)

Obviously this doesn't use the Yahoo API but it is pretty lightweight...

share|improve this answer

Your Answer


