1

Is there a official way to get and display the current correct world gmt time. rather than the computer local time (which you can easily manupulate)

want a trustworthy way to get the current time in hours/minutes. then i can calculate for different zones.

anyone have a good example??

i checked this site the accuraccy of this site is good but how...

thank you!

Awais Qarni
  • 17,492
  • 24
  • 75
  • 137
CCCam
  • 85
  • 3
  • 10

2 Answers2

1
var date = new Date().getTime();
var diff = date.getTimezoneOffset()*60000;
var local_date = new Date(date-diff);

this way, you can get the universal time without any server side scripting. I hope this is what you needed.

eyurdakul
  • 894
  • 2
  • 12
  • 29
  • 1
    ...unless your local clock is wildly inaccurate, which is less common today, but still not rare. – Piskvor left the building May 30 '11 at 13:56
  • yes but depending on the local date is better than depending on an external rest or whatever service. people should know, if you dont set your clock, things won't work. – eyurdakul Sep 30 '11 at 09:24
  • They *should*, indeed :( It is now 2011, decades after digital clocks became widespread; yet I still see many things with clocks blinking at `00:00`, and computer clocks set not hours, not days, but *months* off. Yes, it does break things; as far as I can tell, users are blissfully unaware of time's existence and readily blame anything else. In the presence of an Internet connection, I'll take NTP over trusting the local clock any day. – Piskvor left the building Sep 30 '11 at 09:29
0

See JavaScript NTP time

This person connects to a json service (http://json-time.appspot.com/time.json), which get the NTP time, and converts it to json.

Community
  • 1
  • 1
Gideon
  • 18,251
  • 5
  • 45
  • 64