DateTimeOffset.TimeOfDay Proprietà

Definizione

Ottiene l'ora del giorno per l'oggetto DateTimeOffset corrente.

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

Valore della proprietà

TimeSpan

Intervallo di tempo della data corrente trascorso a partire da mezzanotte.

Esempio

Nell'esempio seguente viene utilizzata la TimeOfDay proprietà per estrarre l'ora e visualizzarla nella console.

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.

Commenti

La TimeOfDay proprietà non è interessata dal valore della Offset proprietà .

La TimeOfDay proprietà restituisce il componente temporale di un DateTimeOffset oggetto sotto forma di TimeSpan oggetto . Equivale alla DateTime.TimeOfDay proprietà .

Si applica a