Date.FormatStyle.Symbol.Month
A type that specifies a format for the month in a date format style.
Declaration
struct MonthOverview
The type Date.FormatStyle.Symbol.Month includes static factory variables that create custom Date.FormatStyle.Symbol.Month objects:
Factory variable | Description |
|---|---|
Abbreviated month name. For example, | |
Minimum number of digits that represents the numeric month. For example, | |
Narrow month name. For example, | |
Two-digit numeric month, zero-padded if necessary. For example, | |
Wide month name. For example, |
To customize the month format in a string representation of a Date, use month(_:). The following example shows a variety of Date.FormatStyle.Symbol.Month format styles applied to a date.
let meetingDate = Date() // Feb 9, 2021 at 3:00 PM
meetingDate.formatted(Date.FormatStyle().month(.abbreviated)) // Feb
meetingDate.formatted(Date.FormatStyle().month(.narrow)) // F
meetingDate.formatted(Date.FormatStyle().month(.defaultDigits)) // 2
meetingDate.formatted(Date.FormatStyle().month(.twoDigits)) // 02
meetingDate.formatted(Date.FormatStyle().month(.wide)) // February
meetingDate.formatted(Date.FormatStyle().month()) // FebIf no format is specified as a parameter, the abbreviated static variable is the default format.
For more information about formatting dates, see the Date.FormatStyle.
Topics
Modifying a Month
Comparing a Month
Type Properties
See Also
Modifying Date Style Format Symbols
Date.FormatStyle.Symbol.CyclicYearDate.FormatStyle.Symbol.DayDate.FormatStyle.Symbol.DayOfYearDate.FormatStyle.Symbol.DayPeriodDate.FormatStyle.Symbol.EraDate.FormatStyle.Symbol.HourDate.FormatStyle.Symbol.MinuteDate.FormatStyle.Symbol.QuarterDate.FormatStyle.Symbol.SecondDate.FormatStyle.Symbol.SecondFractionDate.FormatStyle.Symbol.StandaloneMonthDate.FormatStyle.Symbol.StandaloneQuarterDate.FormatStyle.Symbol.StandaloneWeekdayDate.FormatStyle.Symbol.TimeZoneDate.FormatStyle.Symbol.VerbatimHour