且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何获取访问我网站的用户的当前时间/时区?

更新时间:2023-01-27 15:01:00

改编自: 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.