public void GetNowTest() { DateTime now = DateTime.Now; DateTime sntpNow = SNTPClient.GetNow(); Console.WriteLine("Local Now: {0}, SNTP Now: {1}", now.ToString("yyyy-MM-dd HH:mm.ss.fff"), sntpNow.ToString("yyyy-MM-dd HH:mm.ss.fff")); }
private void lnkNow_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) { DateTime nowDateTime = SNTPClient.GetNow(sntpClient.RemoteSNTPServer, sntpClient.Timeout); string caption = "Current Date & Time"; string text = string.Empty; if (nowDateTime != DateTime.MinValue) { text = string.Format("The real local date and time is:{0}{0}{1}", Environment.NewLine, nowDateTime); } else { text = "There was a problem retrieving the date and time."; } MessageBox.Show(this, text, caption, MessageBoxButtons.OK, MessageBoxIcon.Information); }