DateTimeOffset.Second Propriété
Définition
Important
Certaines informations portent sur la préversion du produit qui est susceptible d’être en grande partie modifiée avant sa publication. Microsoft exclut toute garantie, expresse ou implicite, concernant les informations fournies ici.
Obtient le deuxième composant de l’heure de l’horloge représentée par l’objet actuel DateTimeOffset .
public:
property int Second { int get(); };
public int Second { get; }
member this.Second : int
Public ReadOnly Property Second As Integer
Valeur de propriété
Deuxième composant de l’objet DateTimeOffset , exprimé sous la forme d’une valeur entière comprise entre 0 et 59.
Exemples
L’exemple suivant montre comment afficher le deuxième composant d’un DateTimeOffset objet de trois façons différentes :
En extrayant la valeur de la propriété Second.
En appelant la ToString(String) méthode avec le spécificateur de format « s ».
En appelant la ToString(String) méthode avec le spécificateur de format « 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.
Remarques
La Second propriété n’est pas affectée par la valeur de la Offset propriété.
Vous pouvez également créer une représentation sous forme de chaîne du deuxième composant d’un DateTimeOffset objet en appelant la ToString méthode avec les spécificateurs de format personnalisés « s » ou « ss ».