Hi all I am currently working on a project where when a certain event happens details about the event including the time that the event occurred is added into a list array.
Assuming dateTime1
and dateTime2
are DateTime values:
var diffInSeconds = (dateTime1 - dateTime2).TotalSeconds;
In your case, you 'd use DateTime.Now
as one of the values and the time in the list as the other. Be careful of the order, as the result can be negative if dateTime1
is earlier than dateTime2
.