DateTimeOffset.Day Свойство
Определение
Важно!
Некоторые сведения относятся к предварительной версии продукта, в которую до выпуска могут быть внесены существенные изменения. Майкрософт не предоставляет никаких гарантий, явных или подразумеваемых, относительно приведенных здесь сведений.
Возвращает день месяца, представленный текущим DateTimeOffset объектом.
public:
property int Day { int get(); };
public int Day { get; }
member this.Day : int
Public ReadOnly Property Day As Integer
Значение свойства
Компонент дня текущего DateTimeOffset объекта, выраженный как значение от 1 до 31.
Примеры
В следующем примере показан компонент day объекта DateTimeOffset тремя способами:
Извлекая значение свойства Day.
Вызывая ToString(String) метод с описательом формата "d".
Вызывая ToString(String) метод с описательом формата dd.
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.
Комментарии
Свойство Day не влияет на значение Offset свойства.
Кроме того, можно создать строковое представление дневного DateTimeOffset компонента объекта, вызвав ToString метод с пользовательскими описателями формата "d" или "dd".