DateTimeOffset.Second 속성

정의

현재 DateTimeOffset 개체가 나타내는 클럭 시간의 초 구성 요소를 가져옵니다.

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

속성 값

Int32

DateTimeOffset 개체의 초 구성 요소이며, 0에서 59 사이의 정수 값으로 표현됩니다.

예제

다음 예제에서는 세 가지 방법으로 개체의 DateTimeOffset 두 번째 구성 요소를 표시합니다.

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

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

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

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.
let theTime = DateTimeOffset(2008, 6, 12, 21, 16, 32, DateTimeOffset.Now.Offset)
printfn $"The second component of {theTime} is {theTime.Second}."

printfn $"""The second component of {theTime} is{theTime.ToString " s"}."""

printfn $"The second component of {theTime} is {theTime: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.

설명

속성 값 SecondOffset 영향을 받지 않습니다.

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

적용 대상