TimeElapsed

public static TimeSpan TimeElapsed(this DateTime date)
{
    return DateTime.Now - date;
}
Example:
var myDate = DateTime.Now;
Thread.Sleep(3000);
Console.WriteLine( myDate.TimeElapsed() );
// result -> 00:00:03

Description

Inspiration for this extension method was another DateTime extension that determines difference in current time and a DateTime object. That one returned a string and it is more useful for my applications to have a TimeSpan reference instead. That is what I did with this extension method.

Details

Double click on the code to select all.

 

;