well, it depends a bit on how reliable the system has to be...
of course you can allways say: the code has left your hands -> from now on nothing is reliable ... your code can be tampered with, the hardware is not under your control... so in the end, this task can not be done right, if you consider every possibility
but you can make it a bit harder for someone to tamper with the system...
let's say you have some sort of application state, that is initialized at first start using an internet service that verifies that the software did not expire yet... of course this has to be secured and authenticated with something like TLS and an embedded certificate... (bonus points if you use the bytes from the certificate elsewhere as constants in your program)
now this state has to hold something the program needs to work on, in other words, it is mandatory that this state is affected by changes that are persisted. additionally the state holds the expiry date, and the greatest timestamp your program has seen so far
for example you can have a counter in there that counts operations in your program ... do something, increment the counter, etc
the counter state then is saved along with the data your program is working on, like in a file header, when you write something
of course this information needs some sort of anti-tampering mechanism ... along with the counter state, save the current timestamp and a hash over the file content... then create some sort of signature over the header
when you load that file, verify the signature, the content hash, the timestamp has to be in the past, and the current counter state has to be greater than the saved counter state
the application state is saved the same way on a regular interval and of course you check the state on every startup (expired, greatest known timestamp < current timestamp, signature)
of course someone with brain.exe can poke around a little and dismantle a mechanism like this, but it is a little harder than just reseting a clock
edit:
and of course you can check if there is a filesystem available to write on, that is NTFS formatted, where you can store something hidden in an alternate data stream...
you can also have a config file that you write to AFTER your initial program checks are complete, and compare the last write time of that file to the current system clock to see if it was reset
you can also check for files on the harddrive that are newer than the date the system clock shows you...