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" />
4

2 回答 2

1

我不相信您想要的功能已暴露。我见过的例子是这样的(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;
}

来源:http : //www.phpclasses.org/browse/file/22382.html(免费注册要求)

显然,这不使用 Yahoo API,但它非常轻量级......

于 2010-11-08T03:47:22.153 回答
0

这个问题可以帮助您获取邮政编码的时区。这个答案也可能有帮助。

于 2010-11-01T13:04:03.570 回答