DateTimeOffset.Second Propiedad

Definición

Obtiene el componente de milisegundos de la hora representada por el objeto DateTimeOffset actual.

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

Valor de propiedad

Int32

Componente de segundos del objeto DateTimeOffset, expresado como un valor entero entre 0 y 59.

Ejemplos

En el ejemplo siguiente se muestra el segundo componente de un DateTimeOffset objeto de tres maneras diferentes:

  • Recuperando el valor de la Second propiedad .

  • Llamando al ToString(String) método con el especificador de formato "s".

  • Llamando al ToString(String) método con el especificador de formato "ss".

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.

Comentarios

La Second propiedad no se ve afectada por el valor de la Offset propiedad .

También puede crear una representación de cadena del segundo componente de un DateTimeOffset objeto llamando al ToString método con los especificadores de formato personalizado "s" o "ss".

Se aplica a