DateTimeOffset.TimeOfDay 속성

정의

현재 DateTimeOffset 개체에 대한 하루 중 시간을 가져옵니다.

public:
 property TimeSpan TimeOfDay { TimeSpan get(); };
public TimeSpan TimeOfDay { get; }
member this.TimeOfDay : TimeSpan
Public ReadOnly Property TimeOfDay As TimeSpan

속성 값

TimeSpan

자정을 기준으로 경과한 현재 날짜의 시간 간격입니다.

예제

다음 예제에서는 시간을 추출 하 고 콘솔에 표시 하는 속성을 사용 합니다 TimeOfDay .

DateTimeOffset currentDate = new DateTimeOffset(2008, 5, 10, 5, 32, 16,
                                      DateTimeOffset.Now.Offset);
TimeSpan currentTime = currentDate.TimeOfDay;
Console.WriteLine("The current time is {0}.", currentTime.ToString());
// The example produces the following output:
//       The current time is 05:32:16.
let currentDate = DateTimeOffset(2008, 5, 10, 5, 32, 16, DateTimeOffset.Now.Offset)
let currentTime = currentDate.TimeOfDay
printfn $"The current time is {currentTime}."
// The example produces the following output:
//       The current time is 05:32:16.
Dim currentDate As New DateTimeOffset(#5/10/2008 5:32:16AM#, _
                                      DateTimeOffset.Now.Offset) 
Dim currentTime As TimeSpan = currentDate.TimeOfDay
Console.WriteLine("The current time is {0}.", currentTime.ToString())
' The example produces the following output: 
'       The current time is 05:32:16.

설명

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

이 속성은 TimeOfDay 개체의 형식으로 DateTimeOffset 개체의 TimeSpan 시간 구성 요소를 반환합니다. 속성과 DateTime.TimeOfDay 동일합니다.

적용 대상