There are plenty of
functions to convert datetime to string[
^], but converting back is less easy. You may need to write your own. However unless you need to display the value as a formatted Date & Time, you could just convert it to a simple decimal string, using
cout
or
sprintf
. That would make it much easier to encrypt/decrypt, and convert back to its original value. And finding the difference between two such values is simple maths.