通过邮编获得时区 fetch timezone from zip code
通过邮编获得时区可以通过http://www.geonames.org 提供的服务来做到:
首先你要注册成他的账户,激活免费服务。
然后看其文挡http://www.geonames.org/export/web-services.html
这网站是好人,免费啊。
首先调用Postal Code Search
api.geonames.org/postalCodeSearchJSON?postalcode=邮编参数&maxRows=1&username=你的用户名
此调用返回进度和纬度
{
"postalCodes" : [{
"adminName2" : "Gwinnett",//上级地区名
"adminCode2" : "135",
"adminCode1" : "GA",
"postalCode" : "xxxxxxx",
"countryCode" : "US",
"lng" : -123.123123,
"placeName" : "xxxxxxx",
"lat" : 12.12312312,
"adminName1" : "Georgia"//上上级地区名,省
}]
}
然后调用Timezone Search
http://api.geonames.org/timezoneJSON?lat=纬度参数&lng=经度参数&username=你的用户名
此调用返回目标地区当前时间,时区
{
"time" : "2011-12-29 03:05",
"countryName" : "United States",
"sunset" : "2011-12-29 17:36",
"rawOffset" : -5,
"dstOffset" : -4,
"countryCode" : "US",
"gmtOffset" : -5,
"lng" : -123.123123,
"sunrise" : "2011-12-29 07:41",
"timezoneId" : "America/New_York",
"lat" : 12.12312312
}
