开发者

C#: Check Actual Date Online?

How can 开发者_如何学JAVAI check the actual date and time by using an internet connection? I would like to receive the response from the server as a simple string; I don't want to parse an HTML response.


Here is a post about getting internet time: C#: Get NIST Internet Time


You can find a lot of information on getting date and time from a server here.
Listed on that page are several protocols that are designed to requesting and retrieving date and time:

  • DAYTIME (RFC 867)
  • TIME (RFC 868)
  • NTP (RFC 1305)
  • SNTP (RFC 2030)

From there, you can easily find some public servers that support one of these protocols. Then it's just a matter of writing some code to access one of these servers in a way that conforms to the protocol spec.

Or you can use some that's already been written and made freely available, for example:

Here (DAYTIME protocol) or Here (NTP protocol)


You may find Building Links to World Time Server.com helpful. They offer several approaches.


You should probably look at ntp which is a generic standard for syncing date and time. However windows time already uses that in a domain environment and can be configured to sync against public servers.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜