Gets a date in the future by seconds. - CSharp System

CSharp examples for System:DateTime Second

Description

Gets a date in the future by seconds.

Demo Code

//   The contents of this file are subject to the New BSD
using System;/*w  w w. j av a  2 s  .com*/

public class Main{
        /// <summary>
    /// Gets a date in the future by seconds.
    /// </summary>
    /// <param name="seconds">The seconds.</param>
    /// <returns></returns>
    public static DateTime SecondsFromNow(this int seconds) {
        TimeSpan t = new TimeSpan(0, 0, seconds);
        return DateTime.Now.Add(t);
    }
}

Related Tutorials