How to get the current time/timezone of the user v

2019-08-22 14:50发布

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?

2条回答
等我变得足够好
2楼-- · 2019-08-22 14:59

adapted from: 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>

then post back the variable gmtOffset to your application.

查看更多
Anthone
3楼-- · 2019-08-22 15:06

You can get their ip and look it up via a web service or a database, of which I'm sure someone will reply with, or has already replied with in the duplicate question. :-)

查看更多
登录 后发表回答