DateTimeOffset.Second Propriedade

Definição

Obtém o componente de segundo da hora do relógio representado pelo objeto DateTimeOffset atual.

public:
 property int Second { int get(); };
public int Second { get; }
member this.Second : int
Public ReadOnly Property Second As Integer

Valor da propriedade

Int32

O segundo componente do DateTimeOffset objeto, expresso como um valor inteiro entre 0 e 59.

Exemplos

O exemplo a seguir exibe o segundo componente de um DateTimeOffset objeto de três maneiras diferentes:

DateTimeOffset theTime = new DateTimeOffset(2008, 6, 12, 21, 16, 32,
                             DateTimeOffset.Now.Offset);
Console.WriteLine("The second component of {0} is {1}.",
                  theTime, theTime.Second);

Console.WriteLine("The second component of {0} is{1}.",
                  theTime, theTime.ToString(" s"));

Console.WriteLine("The second component of {0} is {1}.",
                  theTime, theTime.ToString("ss"));
// The example produces the following output:
//    The second component of 6/12/2008 9:16:32 PM -07:00 is 32.
//    The second component of 6/12/2008 9:16:32 PM -07:00 is 32.
//    The second component of 6/12/2008 9:16:32 PM -07:00 is 32.
let theTime = DateTimeOffset(2008, 6, 12, 21, 16, 32, DateTimeOffset.Now.Offset)
printfn $"The second component of {theTime} is {theTime.Second}."

printfn $"""The second component of {theTime} is{theTime.ToString " s"}."""

printfn $"The second component of {theTime} is {theTime:ss}."

// The example produces the following output:
//    The second component of 6/12/2008 9:16:32 PM -07:00 is 32.
//    The second component of 6/12/2008 9:16:32 PM -07:00 is 32.
//    The second component of 6/12/2008 9:16:32 PM -07:00 is 32.
Dim theTime As New DateTimeOffset(#6/12/2008 9:16:32PM#, _
                                       DateTimeOffset.Now.Offset)
Console.WriteLine("The second component of {0} is {1}.", _
                  theTime, theTime.Second)

Console.WriteLine("The second component of {0} is{1}.", _
                  theTime, theTime.ToString(" s"))

Console.WriteLine("The second component of {0} is {1}.", _
                  theTime, theTime.ToString("ss"))
' The example produces the following output:
'    The second component of 6/12/2008 9:16:32 PM -07:00 is 32.
'    The second component of 6/12/2008 9:16:32 PM -07:00 is 32.
'    The second component of 6/12/2008 9:16:32 PM -07:00 is 32.

Comentários

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

Você também pode criar uma representação de cadeia de caracteres do segundo componente de um DateTimeOffset objeto chamando o ToString método com os especificadores de formato personalizado "s" ou "ss".

Aplica-se a