How do I get the current date according to an NTP server without setting it locally?

Posted by Zac B on Super User See other posts from Super User or by Zac B
Published on 2012-12-04T15:35:16Z Indexed on 2012/12/04 17:10 UTC
Read the original article Hit count: 181

Filed under:
|
|
|
|

I want to get the current date and time according to a remote NTP server, using Linux. I don't want to change the local time as a result; I just want to get the remote date, adjusted for the local time zone, printed out. The date returned must comply with the following criteria:

  1. It needs to be reasonably accurate.
  2. It needs to be adjusted for the timezone on the local system making the request.
  3. It needs to be formatted in an easily-readable or interpretable way (standard date format, or seconds since epoch).

What I've Tried:

I can call ntpdate -q my.ntp.server and get the offset between the local time and the server's time, but that doesn't return the date according to the NTP server; it just returns the offset and the local date.

Is there some easy way/command I can use to say: "Print out the date according to a given NTP server, adjusted for my current timezone"?

© Super User or respective owner

Related posts about linux

Related posts about centos