Click here to Skip to main content
15,906,106 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i write a program that store system'DateTime in database with more information ..

my Problem is when a user changed system'datetime for example Returns the last two days or two days go forward...


how can i check computer ' datetime is true ?
Posted
Comments
Avik Ghosh22 31-Jan-15 4:18am    
Use GetUTCDate() in sql server .
http://www.sanssql.com/2010/11/difference-between-getdate-and.html

For critical Now type data i.e. data entry date/time always use the servers date which you are more certain that wouldn't be changed.
 
Share this answer
 
If there is a separate server and there is no real way the server's real time clock can be tampered, than follow Mehdi Gholam's advice and use the server's clock. Actually this is the best practice.

But you haven't dtold us that the database is residig on a differenct machine. In this situation the above statement is useless. You can however use external time sources using NTP and SNTP protocol, to validate local clock (SNTP Client in C#[^]).

Still, if your system is isolated, this won't work either. There are very complicated methos you could implement to detect local time tampering, but I don't know if you really need them.
 
Share this answer
 

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