public static DateTime DataStandardTime() {//返回國際標準時間 //只使用的時間伺服器的IP地址,未使用網域名稱 string[,] 時間伺服器 = new string[14, 2]; int[] 搜尋順序 = new int[] { 3, 2, 4, 8, 9, 6, 11, 5, 10, 0, 1, 7, 12 }; 時間伺服器[0, 0] = "time-a.nist.gov"; 時間伺服器[0, 1] = "129.6.15.28"; 時間伺服器[1, 0] = "time-b.nist.gov"; 時間伺服器[1, 1] = "129.6.15.29"; 時間伺服器[2, 0] = "time-a.timefreq.bldrdoc.gov"; 時間伺服器[2, 1] = "132.163.4.101"; 時間伺服器[3, 0] = "time-b.timefreq.bldrdoc.gov"; 時間伺服器[3, 1] = "132.163.4.102"; 時間伺服器[4, 0] = "time-c.timefreq.bldrdoc.gov"; 時間伺服器[4, 1] = "132.163.4.103"; 時間伺服器[5, 0] = "utcnist.colorado.edu"; 時間伺服器[5, 1] = "128.138.140.44"; 時間伺服器[6, 0] = "time.nist.gov"; 時間伺服器[6, 1] = "192.43.244.18"; 時間伺服器[7, 0] = "time-nw.nist.gov"; 時間伺服器[7, 1] = "131.107.1.10"; 時間伺服器[8, 0] = "nist1.symmetricom.com"; 時間伺服器[8, 1] = "69.25.96.13"; 時間伺服器[9, 0] = "nist1-dc.glassey.com"; 時間伺服器[9, 1] = "216.200.93.8"; 時間伺服器[10, 0] = "nist1-ny.glassey.com"; 時間伺服器[10, 1] = "208.184.49.9"; 時間伺服器[11, 0] = "nist1-sj.glassey.com"; 時間伺服器[11, 1] = "207.126.98.204"; 時間伺服器[12, 0] = "nist1.aol-ca.truetime.com"; 時間伺服器[12, 1] = "207.200.81.113"; 時間伺服器[13, 0] = "nist1.aol-va.truetime.com"; 時間伺服器[13, 1] = "64.236.96.53"; int portNum = 13; string hostName; byte[] bytes = new byte[1024]; int bytesRead = 0; System.Net.Sockets.TcpClient client = new System.Net.Sockets.TcpClient(); for (int i = 0; i < 13; i++) { hostName = 時間伺服器[搜尋順序[i], 1]; try { client.Connect(hostName, portNum); System.Net.Sockets.NetworkStream ns = client.GetStream(); bytesRead = ns.Read(bytes, 0, bytes.Length); client.Close(); break; } catch (System.Exception) { } } char[] sp = new char[1]; sp[0] = ' '; System.DateTime dt = new DateTime(); string str1; str1 = System.Text.Encoding.ASCII.GetString(bytes, 0, bytesRead); string[] s; s = str1.Split(sp); dt = System.DateTime.Parse(s[1] + " " + s[2]);//得到標準時間 dt = dt.AddHours(8);//得到北京時間*/ return dt; }