检测用户时区并使用该时区显示 UTC 时间 [英] Detect user timezone and display UTC time with that timezone

查看:31
本文介绍了检测用户时区并使用该时区显示 UTC 时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个带有 UTC TIMESTAMPS 列的表.我如何用用户时区显示它?Facebook 使用用户计算机的时间设置.Facebook 没有用户设置时区的页面,所以我来宾 Facebook 自动检测它.我如何才能像 Facebook 一样实现?我正在使用 php

I have a table with UTC TIMESTAMPS column. How I display it with user timezone? Facebook uses user computer’s time settings. Facebook has no page for user setting their timezone, so I guest Facebook auto detect it. How I can achieve like Facebook? I'm using php

推荐答案

您无法在服务器端可靠地执行此操作.您可以改为使用 JavaScript 检测用户的时区,但它可能并不完全可靠.

You can't reliably do this on the server side. You can instead detect the user's timezone using JavaScript but it may not be totally reliable.

http://www.onlineaspect.com/2007/06/08/auto-detect-a-time-zone-with-javascript/

这篇关于检测用户时区并使用该时区显示 UTC 时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆