C# DateTimeOffset Month
Description
DateTimeOffset Month
gets the month component of the
date represented by the current DateTimeOffset object.
Syntax
DateTimeOffset.Month
has the following syntax.
public int Month { get; }
Example
The following example displays the month component of a DateTimeOffset value in three different ways:
using System;/*w w w . java 2s . c om*/
public class MainClass{
public static void Main(String[] argv){
DateTimeOffset theTime = new DateTimeOffset(2014, 9, 7, 11, 25, 0,
DateTimeOffset.Now.Offset);
Console.WriteLine("The month component of {0} is {1}.",
theTime, theTime.Month);
Console.WriteLine("The month component of {0} is{1}.",
theTime, theTime.ToString(" M"));
Console.WriteLine("The month component of {0} is {1}.",
theTime, theTime.ToString("MM"));
}
}
The code above generates the following result.