day()
Modifies the ISO 8601 date format style to include the day in the formatted output.
Declaration
func day() -> Date.ISO8601FormatStyleReturn Value
An ISO 8601 date format style modified to include the day.
Discussion
The following example shows an ISO 8601 format with, and without, a day.
let meetingDate = Date() // Jun 23, 2021 at 12:51 PM
meetingDate.formatted(.iso8601
.year()
.month()
)
// 202106
meetingDate.formatted(.iso8601
.year()
.day()
)
// 2021174
meetingDate.formatted(.iso8601
.year()
.month()
.day()
)
// 20210623If month() isn’t included in the format and day() is, the format represents the day as the ordinal date.
The default Date.ISO8601FormatStyle includes the day.
For more information about formatting dates, see the Date.FormatStyle.