You may use this code:
System.Net.Sockets.TcpClient t = new System.Net.Sockets.TcpClient("panic", 13);
System.IO.StreamReader rd = new System.IO.StreamReader(t.GetStream());
MessageBox.Show(rd.ReadToEnd());
but it requires that port 13 on the server is accessible for you.
Or you may try the command line command "net time \\servername" using this code:
System.Diagnostics.ProcessStartInfo psiOpt = new System.Diagnostics.ProcessStartInfo(@"cmd.exe", @"/C net time \\servername");
psiOpt.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
psiOpt.RedirectStandardOutput = true;
psiOpt.UseShellExecute = false;
psiOpt.CreateNoWindow = true;
System.Diagnostics.Process procCommand = System.Diagnostics.Process.Start(psiOpt);
StreamReader srIncoming = procCommand.StandardOutput;
MessageBox.Show(srIncoming.ReadToEnd());
procCommand.WaitForExit();
You then only need to parse the command response for the DateTime.