2

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" />
Community
  • 1
  • 1
Peter M
  • 7,309
  • 3
  • 50
  • 91

2 Answers2

1

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

Basic
  • 26,321
  • 24
  • 115
  • 201
0

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

Community
  • 1
  • 1
jilles de wit
  • 7,060
  • 3
  • 26
  • 50
  • 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 01 '10 at 22:07