从移动设备获取时区?
我正在编写一个应该处理不同时区的移动网站。是否有一个功能可以从移动设备上获取时区?我是基于 php Zend 框架的。
I'm in the midst of programming a mobile site that should deal with different timezones. Is there a function that gets the timezone off the mobile device? I'm php Zend Framework based.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
正是因为设备是移动设备,所以在服务器端确定时区是没有意义的。相反,请使用客户端站点时间。
Precisely because the device is mobile, there is no point in determining the timezone on the server side. Instead, use client-site time.
据我所知,从移动设备获取时区的过程与从桌面客户端获取时区的过程相同。移动浏览器必须支持 JavaScript,否则您必须要求用户选择并提交他们的时区。请参阅此问题:如何获取客户端的时区?
AFAIK the procedure for getting the timezone from a mobile device is the same as getting it from a desktop client. The mobile browser must support JavaScript or you have to ask for the user to choose and submit their timezone. See this question: How to get client's timezone?
没有直接的方法可以做到这一点。您可以根据用户的 IP 地址(地理定位的东西)来估计用户的时区,但这并不准确。
只需看看大多数论坛脚本是如何做到的。一般来说,他们会使用一个小的 JavaScript 来比较服务器时间(区域)和浏览器时间(区域) - 但没有通用的 API 或 HTTP 标头字段。
There's no direct way to do this. You can estimate the user's time zone based on his IP address (geolocationing stuff), but that's not really accurate.
Just have a look at most forum scripts how they do it. In general they'll use a small JavaScript to compare server time(zone) and browser time(zone) - but there's no general API or HTTP header field for this.