CSharp examples for System:TimeSpan
Gets the time span till now.
using System.Globalization; using System;// w ww . j a v a 2s .co m public class Main{ /// <summary> /// Gets the time span till now. /// </summary> /// <param name="input">The input.</param> /// <returns></returns> public static TimeSpan GetTimeSpanTillNow(this DateTime? input) { return new TimeSpan(DateTime.Now.Ticks - Convert.ToDateTime(input).Ticks); } /// <summary> /// Gets the time span till now. /// </summary> /// <param name="input">The input.</param> /// <returns></returns> public static TimeSpan GetTimeSpanTillNow(this DateTime input) { return new TimeSpan(DateTime.Now.Ticks - input.Ticks); } }