DateTimeOffset.Month DateTimeOffset.Month DateTimeOffset.Month DateTimeOffset.Month Property

定義

現在で表される日付の月要素を取得DateTimeOffsetオブジェクト。Gets the month component of the date represented by the current DateTimeOffset object.

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

プロパティ値

現在の月コンポーネントDateTimeOffset1 から 12 までの整数で表されるオブジェクト。The month component of the current DateTimeOffset object, expressed as an integer between 1 and 12.

次の例の月部分の表示、 DateTimeOffset 3 つの異なる方法で値。The following example displays the month component of a DateTimeOffset value in three different ways:

  • 値を取得することによって、Monthプロパティ。By retrieving the value of the Month property.

  • 呼び出すことによって、ToString(String)メソッド"M"書式指定子。By calling the ToString(String) method with the "M" format specifier.

  • 呼び出すことによって、 ToString(String) "MM"書式指定子を持つメソッド。By calling the ToString(String) method with the "MM" format specifier.

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.      
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プロパティ。The Month property is not affected by the value of the Offset property.

文字列表現を作成することも、DateTimeOffset呼び出すことによって、オブジェクトの月コンポーネント、 ToString "M"または"MM"カスタム書式指定子を持つメソッド。You can also create a string representation of a DateTimeOffset object's month component by calling the ToString method with the "M" or "MM" custom format specifiers.

適用対象