DateTimeOffset.Second DateTimeOffset.Second DateTimeOffset.Second DateTimeOffset.Second Property

定義

現在によって表される時刻の秒要素を取得DateTimeOffsetオブジェクト。Gets the second component of the clock time represented by the current DateTimeOffset object.

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

プロパティ値

2 番目のコンポーネント、DateTimeOffsetオブジェクトの 0 から 59 までの整数値で表されます。The second component of the DateTimeOffset object, expressed as an integer value between 0 and 59.

次の例の 2 番目のコンポーネントの表示、 DateTimeOffset 3 つの異なる方法でオブジェクト。The following example displays the second component of a DateTimeOffset object in three different ways:

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

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

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

DateTimeOffset theTime = new DateTimeOffset(2008, 6, 12, 21, 16, 32, 
                             DateTimeOffset.Now.Offset);
Console.WriteLine("The second component of {0} is {1}.", 
                  theTime, theTime.Second);

Console.WriteLine("The second component of {0} is{1}.", 
                  theTime, theTime.ToString(" s"));

Console.WriteLine("The second component of {0} is {1}.", 
                  theTime, theTime.ToString("ss"));
// The example produces the following output:
//    The second component of 6/12/2008 9:16:32 PM -07:00 is 32.
//    The second component of 6/12/2008 9:16:32 PM -07:00 is 32.
//    The second component of 6/12/2008 9:16:32 PM -07:00 is 32.
Dim theTime As New DateTimeOffset(#6/12/2008 9:16:32PM#, _
                                       DateTimeOffset.Now.Offset)
Console.WriteLine("The second component of {0} is {1}.", _
                  theTime, theTime.Second)

Console.WriteLine("The second component of {0} is{1}.", _
                  theTime, theTime.ToString(" s"))

Console.WriteLine("The second component of {0} is {1}.", _
                  theTime, theTime.ToString("ss"))
' The example produces the following output:
'    The second component of 6/12/2008 9:16:32 PM -07:00 is 32.
'    The second component of 6/12/2008 9:16:32 PM -07:00 is 32.
'    The second component of 6/12/2008 9:16:32 PM -07:00 is 32.

注釈

Secondプロパティがの値によって影響を受けません、Offsetプロパティ。The Second property is not affected by the value of the Offset property.

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

適用対象