本文介绍了获取时区偏移量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想获取给定城市的时区偏移量.我正在使用天气在线api. http://api .worldweatheronline.com/free/v1/tz.ashx?q = Lahore& format = json& callback = crm& key = j7cf7epyawudqvbkf3cvc7r2
I want to get time zone offset of given city. I am using weather online api.http://api.worldweatheronline.com/free/v1/tz.ashx?q=Lahore&format=json&callback=crm&key=j7cf7epyawudqvbkf3cvc7r2
它返回
crm({
"data": {
"request": [{
"query": "Lahore, Pakistan",
"type": "City"
}],
"time_zone": [{
"localtime": "2013-11-27 10:46",
**"utcOffset": "5.0"**
}]
}
})
现在我如何使用jSon和jQuery获取utcoffset值 如果有人有想法请与我分享预先感谢
now how I get utcoffset value using jSon and jQuery if anyone have an idea please share with methanks in advance
推荐答案
向您的页面添加crm()
函数(用于回调):
Add a crm()
function to your page (for the callback):
<script>
function crm(timeData) {
// alert first offset
alert(timeData['data']['time_zone'][0]['utcOffset']);
}
</script>
这篇关于获取时区偏移量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!