Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: VB9.0
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 30-Jan-12 4:59am
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

  Permalink  
Comments
Manfred R. Bihy at 30-Jan-12 11:33am
   
Sounds reasonable! Have a 5.
SAKryukov at 30-Jan-12 11:49am
   
Sure, my 5, too.
--SA
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

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
  Permalink  
v2
Comments
SAKryukov at 30-Jan-12 11:49am
   
Right, a 5.
--SA
Manfred R. Bihy at 30-Jan-12 11:59am
   
Thanks SA!
Himachandra at 30-Jan-12 23:18pm
   
nice +5
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

I don't know where you are getting problem,
DateTime.Now
will returns the current system datetime.
 
Thanks
--RA
  Permalink  
Comments
Manfred R. Bihy at 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 ... "
Marcus Kramer at 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)

  Print Answers RSS
0 OriginalGriff 7,903
1 Sergey Alexandrovich Kryukov 7,142
2 DamithSL 5,604
3 Manas Bhardwaj 4,986
4 Maciej Los 4,820


Advertise | Privacy | Mobile
Web03 | 2.8.1411023.1 | Last Updated 30 Jan 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100