DateTimeOffset.TimeOfDay プロパティ
重要
一部の情報は、リリース前に大きく変更される可能性があるプレリリースされた製品に関するものです。 Microsoft は、ここに記載されている情報について、明示または黙示を問わず、一切保証しません。
現在の DateTimeOffset オブジェクトの時刻を取得します。
public:
property TimeSpan TimeOfDay { TimeSpan get(); };
C#
public TimeSpan TimeOfDay { get; }
member this.TimeOfDay : TimeSpan
Public ReadOnly Property TimeOfDay As TimeSpan
現在の日付の午前 0 時からの経過時間。
次の例では、このプロパティを TimeOfDay 使用して時刻を抽出し、コンソールに表示します。
C#
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 同じです。
製品 | バージョン |
---|---|
.NET | Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7 |
.NET Framework | 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8 |
.NET Standard | 1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 2.0, 2.1 |
UWP | 10.0 |