DateTimeOffset.Month 속성

정의

현재 DateTimeOffset 개체가 나타내는 날짜의 월 구성 요소를 가져옵니다.

public:
 property int Month { int get(); };
public int Month { get; }
member this.Month : int
Public ReadOnly Property Month As Integer

속성 값

현재 DateTimeOffset 개체의 월 구성 요소이며, 1에서 12 사이의 정수로 표현됩니다.

예제

다음 예제에서는 세 가지 방법으로 값의 DateTimeOffset 월 구성 요소를 표시합니다.

  • 값을 검색 하 여 Month 속성입니다.

  • "M" 형식 지정자를 사용하여 메서드를 호출 ToString(String) 합니다.

  • "MM" 형식 지정자를 사용하여 메서드를 호출 ToString(String) 합니다.

DateTimeOffset theTime = new DateTimeOffset(2008, 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 example produces the following output:
//    The month component of 9/7/2008 11:25:00 AM -08:00 is 9.
//    The month component of 9/7/2008 11:25:00 AM -08:00 is 9.
//    The month component of 9/7/2008 11:25:00 AM -08:00 is 09.
let theTime = DateTimeOffset(2008, 9, 7, 11, 25, 0, DateTimeOffset.Now.Offset)
printfn $"The month component of {theTime} is {theTime.Month}."

printfn $"""The month component of {theTime} is{theTime.ToString " M"}."""

printfn $"""The month component of {theTime} is {theTime.ToString "MM"}."""

// The example produces the following output:
//    The month component of 9/7/2008 11:25:00 AM -08:00 is 9.
//    The month component of 9/7/2008 11:25:00 AM -08:00 is 9.
//    The month component of 9/7/2008 11:25:00 AM -08:00 is 09.
Dim theTime As New DateTimeOffset(#9/7/2008 11:25AM#, _
                                       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 example produces the following output:
'    The month component of 9/7/2008 11:25:00 AM -08:00 is 9.
'    The month component of 9/7/2008 11:25:00 AM -08:00 is 9.
'    The month component of 9/7/2008 11:25:00 AM -08:00 is 09.

설명

속성은 Month 속성 값의 Offset 영향을 받지 않습니다.

"M" 또는 "MM" 사용자 지정 형식 지정자를 사용하여 메서드를 ToString 호출하여 개체의 월 구성 요소에 대한 문자열 표현 DateTimeOffset 을 만들 수도 있습니다.

적용 대상