如何获取访问我网站的用户的当前时间/时区? [英] How to get the current time/timezone of the user visiting my website?

查看:190
本文介绍了如何获取访问我网站的用户的当前时间/时区?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个使用PHP(Zend Framework)和JavaScript(jQuery)的应用程序.

I am working on an application which utilizes PHP (Zend Framework) and JavaScript (jQuery).

我正在尝试获取用户访问该网站的当前时间.这可能吗?该怎么办?

I'm trying to get the current time of the user visiting the site. Is this possible? How can this be done?

推荐答案

改编自: http://kennyshu.blogspot.com/2009/05/javascript-get-clients-timezone.html

  <script type="text/javascript"> 
  var gmtOffset
  function timezone()  
  {  
    var localTime = new Date();  
    //this one will give you the GMT offset  
    gmtOffset = localTime.getTimezoneOffset()/60 * (-1);  
  }  
  </script>

然后将变量gmtOffset发回到您的应用程序中.

then post back the variable gmtOffset to your application.

这篇关于如何获取访问我网站的用户的当前时间/时区?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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