DateTimeOffset.TimeOfDay Propiedad

Definición

Obtiene la hora del día del objeto DateTimeOffset actual.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

Valor de propiedad

Intervalo de tiempo de la fecha actual que ha transcurrido desde la medianoche.The time interval of the current date that has elapsed since midnight.

Ejemplos

En el ejemplo siguiente se usa la propiedad TimeOfDay para extraer la hora y mostrarla en la consola.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.

Comentarios

La propiedad TimeOfDay no se ve afectada por el valor de la propiedad Offset.The TimeOfDay property is not affected by the value of the Offset property.

La propiedad TimeOfDay devuelve el componente de hora de un objeto DateTimeOffset en forma de un objeto TimeSpan.The TimeOfDay property returns the time component of a DateTimeOffset object in the form of a TimeSpan object. Es equivalente a la propiedad DateTime.TimeOfDay.It is equivalent to the DateTime.TimeOfDay property.

Se aplica a