DateTimeOffset.TimeOfDay Eigenschaft

Definition

Ruft die Uhrzeit für das aktuelle DateTimeOffset-Objekt ab.Gets the time of day for the current DateTimeOffset object.

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

Eigenschaftswert

Das Zeitintervall des aktuellen Datums, das seit Mitternacht verstrichen ist.The time interval of the current date that has elapsed since midnight.

Beispiele

Im folgenden Beispiel wird die TimeOfDay -Eigenschaft verwendet, um die Uhrzeit zu extrahieren und in der Konsole anzuzeigen.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, 
                                      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.
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.

Hinweise

Die- Offset Eigenschaft wird nicht durch den Wert der-Eigenschaft beeinflusst. TimeOfDayThe TimeOfDay property is not affected by the value of the Offset property.

Die TimeOfDay -Eigenschaft gibt die Zeitkomponente DateTimeOffset eines-Objekts TimeSpan in Form eines-Objekts zurück.The TimeOfDay property returns the time component of a DateTimeOffset object in the form of a TimeSpan object. Dies entspricht der DateTime.TimeOfDay -Eigenschaft.It is equivalent to the DateTime.TimeOfDay property.

Gilt für: