minute(_:)
Modifies the date format style to use the specified minute format style.
Declaration
func minute(_ format: Date.FormatStyle.Symbol.Minute = .defaultDigits) -> Date.FormatStyleParameters
- format:
The minute format style applied to the date format style.
Return Value
A date format style modified to include the specified minute style.
Discussion
Values of Date.FormatStyle.Symbol.Minute are defaultDigits and twoDigits.
This example shows a variety of Date.FormatStyle.Symbol.Minute format styles applied to a date:
let meetingDate = Date() // Feb 9, 2021 at 3:05 PM
meetingDate.formatted(Date.FormatStyle().minute(.defaultDigits)) // 5
meetingDate.formatted(Date.FormatStyle().minute(.twoDigits)) // 05
meetingDate.formatted(Date.FormatStyle().minute()) // 5If you don’t provide a format, the defaultDigits static variable is the default format.
For more information about formatting dates, see Date.FormatStyle.