C# DateTimeOffset AddMonths
Description
DateTimeOffset AddMonths
adds a specified number of
months to the current DateTimeOffset object.
Syntax
DateTimeOffset.AddMonths
has the following syntax.
public DateTimeOffset AddMonths(
int months
)
Parameters
DateTimeOffset.AddMonths
has the following parameters.
months
- A number of whole months. The number can be negative or positive.
Returns
DateTimeOffset.AddMonths
method returns An object whose value is the sum of the date and time represented by the current
DateTimeOffset object and the number of months represented by months.
Example
The following example uses the AddMonths method.
using System;/* ww w . j av a 2 s . co m*/
public class MainClass{
public static void Main(String[] argv){
DateTimeOffset quarterDate = new DateTimeOffset(2014, 1, 1, 0, 0, 0,
DateTimeOffset.Now.Offset);
quarterDate = quarterDate.AddMonths(3);
Console.WriteLine(quarterDate);
}
}
The code above generates the following result.