DateTimeOffset.Day Eigenschaft

Definition

Ruft den Tag des Monats ab, der durch das aktuelle DateTimeOffset-Objekt dargestellt wird.

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

Eigenschaftswert

Int32

Die Tagkomponente des aktuellen DateTimeOffset-Objekts als Wert zwischen 1 und 31.

Beispiele

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

  • Durch Abrufen des Werts der Day Eigenschaft.

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

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

DateTimeOffset theTime = new DateTimeOffset(2007, 5, 1, 16, 35, 0,
                                            DateTimeOffset.Now.Offset);
Console.WriteLine("The day component of {0} is {1}.",
                  theTime, theTime.Day);

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

Console.WriteLine("The day component of {0} is {1}.",
                  theTime, theTime.ToString("dd"));
// The example produces the following output:
//    The day component of 5/1/2007 4:35:00 PM -08:00 is 1.
//    The day component of 5/1/2007 4:35:00 PM -08:00 is 1.
//    The day component of 5/1/2007 4:35:00 PM -08:00 is 01.
let theTime = DateTimeOffset(2007, 5, 1, 16, 35, 0, DateTimeOffset.Now.Offset)
printfn $"The day component of {theTime} is {theTime.Day}."

printfn $"""The day component of {theTime} is{theTime.ToString " d"}."""

printfn $"The day component of {theTime} is {theTime:dd}."

// The example produces the following output:
//    The day component of 5/1/2007 4:35:00 PM -08:00 is 1.
//    The day component of 5/1/2007 4:35:00 PM -08:00 is 1.
//    The day component of 5/1/2007 4:35:00 PM -08:00 is 01.
Dim theTime As New DateTimeOffset(#5/1/2007 4:35PM#, _
                                       DateTimeOffset.Now.Offset)
Console.WriteLine("The day component of {0} is {1}.", _
                  theTime, theTime.Day)

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

Console.WriteLine("The day component of {0} is {1}.", _
                  theTime, theTime.ToString("dd"))
' The example produces the following output:
'    The day component of 5/1/2007 4:35:00 PM -08:00 is 1.
'    The day component of 5/1/2007 4:35:00 PM -08:00 is 1.
'    The day component of 5/1/2007 4:35:00 PM -08:00 is 01.

Hinweise

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

Sie können auch eine Zeichenfolgendarstellung der Tageskomponente eines DateTimeOffset Objekts erstellen, indem Sie die ToString Methode mit den benutzerdefinierten Formatbezeichnern "d" oder "dd" aufrufen.

Gilt für