Returns a new datetime instance, representing a point in time lesser than the current by specified . - CSharp System

CSharp examples for System:DateTime Convert

Description

Returns a new datetime instance, representing a point in time lesser than the current by specified .

Demo Code


using System.Globalization;
using System;//from ww w .ja  v a  2  s. c  om

public class Main{
        /// <summary>
    ///   <para>Returns a new date/time instance, representing a point in time lesser than the current by specified <see cref="TimeSpan"/>.</para>
    /// </summary>
    /// <param name="self">Time span to substract from current date/time.</param>
    /// <returns>Current date/time, decremented by the <paramref name="self"/>, expressed as a local time.</returns>
    public static DateTime BeforeNow(this TimeSpan self)
    {
      return DateTime.Now.Subtract(self);
    }
}

Related Tutorials