Catch the time on a remote computer using C#

Asked

Viewed 96 times

5

Is there any method for me to recover time and date from a remote computer using C#?

  • http://stackoverflow.com/a/2836996/2221388 you have tried this OS reply?

1 answer

5


I found a solution using WMI in response in OS. You don’t like her.

has also a solution calling the net time, horrible for my taste.

There are other solutions there.

I prefer the solution using NTP in another OS response. To Example implementation can be seen here. With the use adopted in another response in the OS:

InternetTime.SNTPClient sntp = new InternetTime.SNTPClient("ntp1.ja.net");
sntp.Connect(false); // true to update local client clock
DateTime dt = sntp.DestinationTimestamp.AddMilliseconds(sntp.LocalClockOffset);
var timeStampNow = dt.ToString("dd/MM/yyyy HH:mm:ss.fff");

I put in the Github for future reference.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.