开发者

How to get location based time?

开发者 https://www.devze.com 2023-04-13 05:54 出处:网络
i am working on javascript which displays time based on location, 开发者_如何学运维that is if a user logs on from china it should display their local time or a user from india it should display their

i am working on javascript which displays time based on location, 开发者_如何学运维that is if a user logs on from china it should display their local time or a user from india it should display their code.No matter what, i am not able to get the code.pls someone help.


You can get the users local time in JS with:

  var currentTime = new Date()
  var hours = currentTime.getHours()
  var minutes = currentTime.getMinutes()

  if (minutes < 10)
  minutes = "0" + minutes

  document.write("<b>" + hours + ":" + minutes + " " + "</b>")
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号