0

i came across this code which shows the current time of the user based on his timezone. Based on this can we tell if he is on IST or EST.plz help

<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>
hakre
  • 193,403
  • 52
  • 435
  • 836
Sibu
  • 42
  • 6
  • A similar question has already been posed and answered: [Get client timezone (not GMT offset amount) in JS](http://stackoverflow.com/questions/2897478/get-client-timezone-not-gmt-offset-amount-in-js) Please use the search function next time. See as well the [FAQ](http://stackoverflow.com/faq). – hakre Oct 13 '11 at 12:03
  • yeah i know this code, but can we tell which timezone he is from??,like i wanted to display the time along with timezone.for example 17:35 IST – Sibu Oct 13 '11 at 12:05

2 Answers2

1

i wanted to display the time along with timezone.for example 17:35 IST

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

which will return something like "12:21:44 GMT-0400 (EDT)"

hakre
  • 193,403
  • 52
  • 435
  • 836
0

You cannot tell what timezone he is in - just what time they are in based on GMT - use this useful function to get your info though -> http://www.pageloom.com/automatic-timezone-detection-with-javascript

Manse
  • 37,765
  • 10
  • 83
  • 108