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.





















Home »
  C# Tutorial »
    System »




Array
BitConverter
Boolean
Byte
Char
Console
ConsoleKeyInfo
Convert
DateTime
DateTimeOffset
Decimal
Double
Enum
Environment
Exception
Guid
Int16
Int32
Int64
Math
OperatingSystem
Random
SByte
Single
String
StringComparer
TimeSpan
TimeZone
TimeZoneInfo
Tuple
Tuple
Tuple
Type
UInt16
UInt32
UInt64
Uri
Version