Click here to Skip to main content
15,886,199 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How can we get date and time of computer at realtime ?
Means, If someone changes date and time of computer, how can we get the actual date and time in .net 2008 ?
Posted

 
Share this answer
 
Comments
Manfred Rudolf Bihy 30-Jan-12 11:33am    
Sounds reasonable! Have a 5.
Sergey Alexandrovich Kryukov 30-Jan-12 11:49am    
Sure, my 5, too.
--SA
If the user has the right to change the systems date and time there is no easy solution for you. You could of course try to detect if such a change was made, but that will not help you in correcting it.

Here are two solutions to your problem:

  1. If the computer has access to the internet you can get the correct date and UTC time using a timeserver on the net and the SNTP protocol as proposed in this solution: Simple Network Time (NTP) Protocol Client [^]
  2. The next best thing I could think of is still harder to do and also costlier as it would require bundling a hardware dongle with your software that would include a time keeping mechanism (Calendar & Clock).


Hope that helps,

Manfred
 
Share this answer
 
v2
Comments
Sergey Alexandrovich Kryukov 30-Jan-12 11:49am    
Right, a 5.
--SA
Manfred Rudolf Bihy 30-Jan-12 11:59am    
Thanks SA!
Himachandra 30-Jan-12 23:18pm    
nice +5
I don't know where you are getting problem,
VB
DateTime.Now

will returns the current system datetime.

Thanks
--RA
 
Share this answer
 
Comments
Manfred Rudolf Bihy 30-Jan-12 10:53am    
My vote of one:
OP explicitely stated that the correct time needs to be retrieved even if the systems time and/or date was altered:
"If someone changes date and time of computer, how can we get the actual date and time ... "
fjdiewornncalwe 30-Jan-12 11:16am    
1 - Exactly the reason why Manfred gave you a one as well. You need to read the question more carefully before answering.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900