DateTimeOffset.TimeOfDay プロパティ


現在の DateTimeOffset オブジェクトの時刻を取得します。Gets the time of day for the current DateTimeOffset object.

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


現在の日付の午前 0 時からの経過時間。The time interval of the current date that has elapsed since midnight.

次の例では、TimeOfDay プロパティを使用して時間を抽出し、コンソールに表示します。The following example uses the TimeOfDay property to extract the time and display it to the console.

DateTimeOffset currentDate = new DateTimeOffset(2008, 5, 10, 5, 32, 16,
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.
Dim currentDate As New DateTimeOffset(#5/10/2008 5:32:16AM#, _
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 プロパティの値の影響を受けません。The TimeOfDay property is not affected by the value of the Offset property.

TimeOfDay プロパティは、DateTimeOffset オブジェクトの時刻部分を TimeSpan オブジェクトの形式で返します。The TimeOfDay property returns the time component of a DateTimeOffset object in the form of a TimeSpan object. これは、DateTime.TimeOfDay プロパティと同じです。It is equivalent to the DateTime.TimeOfDay property.