2

Essentially, I want to get an accurate time from a public NTP server, in DOS or powershell.
I know there's the w32tm which can query a remote ntp server, but the result it gives is how much out my computer time is, not the actual time of the remote ntp server.

I've found various windows apps that work exactly as I want, but i can't get the output to a variable to do anything with. I'm dead surprised there's no .exe that just gets the time from a source, or that it wasn't written into w32tm.

Something like ntpquery.exe pool.ntp.org (followed maybe like a timezone or something) with an output of the date / time is all I'm after.


I know there's a command on another question that shows this result:

w32tm /stripchart /computer:foo
Tracking foo [1.2.3.4].
The current time is 19/07/2012 17:39:48 (local time).
17:39:48 d:-00.0000840s o:-25.3004160s  [@                          |                           ]

This shows the local system time (which could and in my case is wrong) and how much out it is to the NTP server (example above is 0.00000840s)

If I run this I could get a result of +/- 3000 seconds or even more, which doesn't give me the actual time of the NTP server just tells me how out I am.


What I'm looking for is a way to get the time from the NTP source in DOS / powershell so I can use it as a variable.

Gnoupi
  • 8,188

1 Answers1

0

Thanks for all the responses... esp CraftyB.... though I figured out a way to do it in the end and thought I'd share with.

What I did was use this app here (free) https://www.meinbergglobal.com/english/sw/ntp.htm Installed.. then took the libcrypto-1_1.dll and ntpdate.exe from the installation and scripted that to get the result from a remote ntp server.

Works fab. Thanks so much for everyone's input - and CraftyB your response is a valid answer that also works.. so I may migrate to that in the end !