DateTimeOffset.TimeOfDay Propriedade

Definição

Obtém a hora do dia para o objeto DateTimeOffset atual.

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

Valor da propriedade

TimeSpan

O intervalo da data atual decorrido desde a meia-noite.

Exemplos

O exemplo a seguir usa a TimeOfDay propriedade para extrair a hora e exibi-la no 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.

Comentários

A TimeOfDay propriedade não é afetada pelo valor da Offset propriedade.

A TimeOfDay propriedade retorna o componente de tempo de um DateTimeOffset objeto na forma de um TimeSpan objeto. É equivalente à DateTime.TimeOfDay propriedade.

Aplica-se a