My C# application is dependent on system date and time and i want to check the date-time of the system on application start-up from internet. But i don't know how to do it?
Asked
Active
Viewed 975 times
1
-
Guess you can reuse some 3rd party SNTP libraries. Googled?? – Zenwalker Jan 10 '12 at 09:03
-
1what do you want, it a bit unclear: the dateTime of the system or the dateTime of the internet? – Moonlight Jan 10 '12 at 09:03
-
1possible duplicate of [C# - Best way to retrieve accurate date?](http://stackoverflow.com/questions/1682350/c-sharp-best-way-to-retrieve-accurate-date) – V4Vendetta Jan 10 '12 at 09:04
-
possible duplicate of [How to Query an NTP Server from C#](http://stackoverflow.com/questions/1193955/how-to-query-an-ntp-server-from-c-sharp) – slugster Jan 10 '12 at 09:16
-
i want to update the date-time of the system from the internet automatically in application start-up. – Mohammad Zare Jan 10 '12 at 09:22
2 Answers
2
The way you describe it's not so simple.
If you absolutely have synchronize system's time take a look at this project. It involves calling windows system api and I'm pretty sure you'll need high privileges to run that code.
If you just need to get time from the internet for your application this question has the answer for you.
1
I tried lot of solution's but the one below worked for me .
Process.Start("time", DateTime.Now.ToString());
just use Process Class and CMD to change the Time ,and i think you will need Administrator Privilege for that .
You can use this class to get the time from an NTP Server .

Rosmarine Popcorn
- 10,761
- 11
- 59
- 89
-
but it seems that this instruction won't change the date time in anyway ? it replaces system date time with itself – geogeek Apr 15 '13 at 15:20
-