.Net API to get exact time for Internet Time Server

后端 未结 4 788
春和景丽
春和景丽 2021-01-06 12:19

I need to know if there is any .NET API exists to fetch the current time from Internet Time Server, so that changing the system time at the client will not affect the integr

相关标签:
4条回答
  • 2021-01-06 12:46

    Ah - no. Simple like that. No NTP support.

    0 讨论(0)
  • 2021-01-06 12:49

    There's a third party library that should bail you out. See the NtpClient class

    For other alternatives, see the similar thread here

    0 讨论(0)
  • 2021-01-06 12:54

    You can use third party NTPClient.cs.

    Example how to use:

    DateTime time_nist_gov = NTPClient.GetTime().TransmitTimestamp; // uses NTPClient.DefaultTimeServer = "time.nist.gov"
    DateTime time_windows_com = NTPClient.GetTime("time.windows.com").TransmitTimestamp;
    DateTime pool_ntp_org = NTPClient.GetTime("pool.ntp.org").TransmitTimestamp;
    
    0 讨论(0)
  • 2021-01-06 13:06

    you have several options - though none built-in:

    • http://dotnet-snippets.com/dns/simple-network-time-ntp-protocol-client-SID571.aspx
    • http://www.codeproject.com/KB/IP/ntpclient.aspx
    • http://www.codeproject.com/KB/datetime/SNTPClient.aspx
    • http://www.rebex.net/time.net/ (commercial)
    0 讨论(0)
提交回复
热议问题