ExtensionMethod.NET Home of 880 C#, Visual Basic, F# and Javascript extension methods

ElapsedSeconds

Gest the elapsed seconds since the input DateTime

Source

/// <summary>
/// Gest the elapsed seconds since the input DateTime
/// </summary>
/// <param name="input">Input DateTime</param>
/// <returns>Returns a Double value with the elapsed seconds since the input DateTime</returns>
/// <example>
/// Double elapsed = dtStart.ElapsedSeconds();
/// </example>
/// <seealso cref="Elapsed()"/>
public static Double ElapsedSeconds(this DateTime input)
{
        return DateTime.Now.Subtract(input).TotalSeconds;
}

Example

DateTime dtStart = DateTime.Now;
// Do something
Double elapsed = dtStart.ElapsedSeconds();

Author: Jonnidip

Submitted on: 30 nov. 2010

Language: C#

Type: System.DateTime

Views: 5571