DateTimeOffset.TimeOfDay Tulajdonság
Definíció
Fontos
Egyes információk olyan, kiadás előtti termékekre vonatkoznak, amelyek a kiadásig még jelentősen módosulhatnak. A Microsoft nem vállal kifejezett vagy törvényi garanciát az itt megjelenő információért.
Lekéri az aktuális DateTimeOffset objektum napjának idejét.
public:
property TimeSpan TimeOfDay { TimeSpan get(); };
public TimeSpan TimeOfDay { get; }
member this.TimeOfDay : TimeSpan
Public ReadOnly Property TimeOfDay As TimeSpan
Tulajdonság értéke
Az aktuális dátum éjfél óta eltelt időintervalluma.
Példák
Az alábbi példa a tulajdonságot használja az TimeOfDay idő kinyerésére és a konzolon való megjelenítésére.
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.
Megjegyzések
A TimeOfDay tulajdonság értékét nem befolyásolja a Offset tulajdonság értéke.
A TimeOfDay tulajdonság egy objektum időösszetevőjét DateTimeOffset adja vissza objektum formájában TimeSpan . Ez a tulajdonságnak DateTime.TimeOfDay felel meg.