Date.FormatStyle.DateStyle
Type that defines date styles varied in length or components included.
Declaration
struct DateStyleOverview
The exact format depends on the locale. Possible values of date style include omitted, numeric, abbreviated, long, and complete.
The following code sample shows a variety of date style format results using the en_US locale.
let meetingDate = Date()
meetingDate.formatted(date: .omitted, time: .standard)
// 9:42:14 AM
meetingDate.formatted(date: .numeric, time: .omitted)
// 10/17/2020
meetingDate.formatted(date: .abbreviated, time: .omitted)
// Oct 17, 2020
meetingDate.formatted(date: .long, time: .omitted)
// October 17, 2020
meetingDate.formatted(date: .complete, time: .omitted)
// Saturday, October 17, 2020
meetingDate.formatted()
// 10/17/2020, 9:42 AMThe default date style is numeric.