Freigeben über


DateTimeOffset.Second Eigenschaft

Definition

Ruft die zweite Komponente der Uhrzeit, dargestellt durch das aktuelle DateTimeOffset Objekt.

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

Eigenschaftswert

Die zweite Komponente des DateTimeOffset Objekts, ausgedrückt als ganzzahliger Wert zwischen 0 und 59.

Beispiele

Im folgenden Beispiel wird die zweite Komponente eines DateTimeOffset Objekts auf drei verschiedene Arten angezeigt:

  • Durch Abrufen des Werts der Second-Eigenschaft.

  • Durch Aufrufen der ToString(String) Methode mit dem Formatbezeichner "s".

  • Durch Aufrufen der ToString(String) Methode mit dem Formatbezeichner "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.

Hinweise

Die Second Eigenschaft ist vom Wert der Offset Eigenschaft nicht betroffen.

Sie können auch eine Zeichenfolgendarstellung der zweiten Komponente eines DateTimeOffset Objekts erstellen, indem Sie die ToString Methode mit den benutzerdefinierten Formatbezeichnern "s" oder "ss" aufrufen.

Gilt für: