Hello All,
I am using C# to send an email with an encrypted link. The encrypted portion of the link contains a time stamp that needs to be used to verify if the link is more than 48 hours old. How do I compare an old time to the current time and find out if the old time is 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 it's a very backwards way to do it and I know that the hours.CompareTo would have to be adjusted if I stick with comparing ticks. How can I just get a value for the number of hours that have passed?