Reputation: 1369
A part of the application that I am building should be accessed only during a particular time period.
I know we can get the current system time using the properties of DateTime
in C#. If I use DateTime
properties then the users can change their system time and access the part of application when ever they want.
Please let me know how to get the ACTUAL current time in C#.
Upvotes: 3
Views: 6354
Reputation: 23695
Have a look at this implementation of NTP client: http://dotnet-snippets.com/dns/simple-network-time-ntp-protocol-client-SID571.aspx
Upvotes: 2
Reputation: 18863
If the system date is wrong, then your application has to get the correct date from somewhere else. That means and outside resource perhap a web service or other local remote server.
Upvotes: 0
Reputation: 39079
You can query an NTP server. NTP servers provide you with the current time, and allowing you to be very accurate (that's how computers synchronize clocks).
See an example here
Upvotes: 4
Reputation: 44068
You need to query some NTP servers to get the actual current time, such as www.pool.ntp.org
Upvotes: 2