Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is DateTime.Now affected by changing the system clock?

Tags:

c#

datetime

If I use DateTime.Now as part of software licensing authentication to enforce the number of days software can be used, can this be circumvented by simply changing the system clock?

If so is there a better way to get real UTC time?

like image 626
Dr. Andrew Burnett-Thompson Avatar asked Apr 13 '12 20:04

Dr. Andrew Burnett-Thompson


People also ask

Does DateTime now use system time?

The Now property returns a DateTime value that represents the current date and time on the local computer.

How accurate is DateTime now?

From MSDN you'll find that DateTime. Now has an approximate resolution of 10 milliseconds on all NT operating systems.

What timezone does DateTime now return?

The property UtcNow of the DateTime class returns the current date and time of the machine running the code, expressed in UTC format. UTC is a universal format to represent date and time as an alternative to local time. Also known as the GMT+00 timezone.


1 Answers

If I use DateTime.Now as part of software licensing authentication to enforce the number of days software can be used, can this be circumvented by simply changing the system clock?

DateTime.Now uses the system clock, so yes it could be circumvented.

If so is there a better way to get accurate system time?

Yes, you could query a time server over the www. But you know, even this could be circumvented because the user can modify his hosts file and replace the address you are using with his own proxy and return whatever time he likes. So it will all depend on how far do you want to get into protecting your software. If you really care about the intellectual property of your software you are better of purchasing a commercial licensing software.

like image 112
Darin Dimitrov Avatar answered Nov 05 '22 06:11

Darin Dimitrov