rookie_developer
rookie_developer

Reputation: 1369

get ACTUAL date time and not system date time in C#

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

Answers (4)

Tommaso Belluzzo
Tommaso Belluzzo

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

MethodMan
MethodMan

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

zmbq
zmbq

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

Fede
Fede

Reputation: 44068

You need to query some NTP servers to get the actual current time, such as www.pool.ntp.org

Upvotes: 2

Related Questions