2

I have found certain online time servers that share accurate time when provided with proper time zones. For example:

  • time.windows.com
  • time.nist.gov
  • time-nw.nist.gov
  • time-a.nist.gov
  • time-b.nist.gov

are some time servers that are used by Windows to auto-update time over internet. I want to use these servers to determine the accurate time instead of local server time or client system time. I tried querying as : http://time.windows.com/?timezone=GMT+5:30 (get request) expecting to get current time in India but it said: Error : 403.

So, I would like to know , What's the right format to query such time server to get the time & date in response. Codes using any ne of html (get)(post), php, js, jquery is/are acceptable.

Thanks !

Anirban
  • 550
  • 3
  • 19

1 Answers1

2

You should not do this from your application code. As you are pointing out there are "some time servers that are used by Windows to auto-update time over internet." So, use an appropriate client program/service to set your server's time on a regular bases. This way your server's clock will always be accurate to the microsecond level. Attempting to query a time-server on a per request bases (as your description suggests) is foolish and causes a great deal of unnecessary overhead.

marekful
  • 14,986
  • 6
  • 37
  • 59
  • I understand that..... But what if we realy need accuracy assurance???? We know that local system time is vulnerable to attacks!!! May be malware etc. that can mess with system time & client time is unreliable, thuswe need a third party to cross check. – Anirban Feb 19 '14 at 17:20
  • 1
    That's why I suggested to use a NIST (or other) client service on your webserver. Then, you can sample the time (of incoming requests, for e.g.) from your server's clock. Or you mean that you are worried that your server time will be hacked and in that case you want an alternative way to get the time? Even if it is "hacked", these services work in a way that your server time will be synced from an Internet Atomic clock say every half an hour (you can configure how oftern). No real risk. – marekful Feb 19 '14 at 17:23