C # check age of db Item
I am using C # to send an email with an encrypted link. The encrypted portion of the link contains a timestamp that should be used to check if the link is more than 48 hours old. How can I compare the old time with the current time and find out if the old time was more than 48 hours ago?
This is what I have now:
var hours = DateTime.Now.Ticks - data.DTM.Value.Ticks; //data.DTM = stored time stamp
if (hours.CompareTo(48) > 1) //if link is more than 48 hours old, deny access.
return View("LinkExpired");
}
Comparing ticks seems like a very reverse way of doing it, and I know hours.CompareTo will have to be adjusted if I stick to comparing ticks. How can I just get a value for the number of hours passed?
+2
source to share