我们可以根据GMT得到用户的时区吗?

Can we get timezone of a user based on GMT

本文关键字:用户 时区 GMT 我们      更新时间:2023-09-26

我遇到了这段代码,它根据用户的时区显示用户的当前时间。基于此,我们可以判断他是在IST还是est .请帮助

<script type="text/javascript">
    var currentTime = new Date()
      var hours = currentTime.getHours()
      var minutes = currentTime.getMinutes()
      if (minutes < 10)
      minutes = "0" + minutes
      document.write("<b>" + hours + ":" + minutes + " " + "</b>")
      </script>

我想显示时间和时区。例如17:35 IST

var now = new Date();
localtime = now.toTimeString();

将返回类似"12:21:44 GMT-0400 (EDT)"的内容

你不能告诉他在哪个时区-只是他们在GMT的时间-使用这个有用的函数来获取你的信息-> http://www.pageloom.com/automatic-timezone-detection-with-javascript