从移动设备获取时区?

发布于 2024-11-28 13:48:29 字数 66 浏览 2 评论 0原文

我正在编写一个应该处理不同时区的移动网站。是否有一个功能可以从移动设备上获取时区?我是基于 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

烂人 2024-12-05 13:48:29

正是因为设备是移动设备,所以在服务器端确定时区是没有意义的。相反,请使用客户端站点时间

Precisely because the device is mobile, there is no point in determining the timezone on the server side. Instead, use client-site time.

静水深流 2024-12-05 13:48:29

据我所知,从移动设备获取时区的过程与从桌面客户端获取时区的过程相同。移动浏览器必须支持 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?

辞取 2024-12-05 13:48:29

没有直接的方法可以做到这一点。您可以根据用户的 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文