secondFraction(_:)
Modifies the date format style to use the specified second fraction format style.
Declaration
func secondFraction(_ format: Date.FormatStyle.Symbol.SecondFraction) -> Date.FormatStyleParameters
- format:
The second fraction format style applied to the date format style.
Return Value
A date format style modified to include the specified second fraction style.
Discussion
Static methods that return Date.FormatStyle.Symbol.SecondFraction objects include fractional(_:) and milliseconds(_:).
This example shows a variety of Date.FormatStyle.Symbol.SecondFraction format styles applied to a date:
let meetingDate = Date() // Feb 9, 2021 at 3:05:41.827 PM
meetingDate.formatted(Date.FormatStyle().secondFraction(.fractional(3))) // 827
meetingDate.formatted(Date.FormatStyle().secondFraction(.fractional(1))) // 8
meetingDate.formatted(Date.FormatStyle().secondFraction(.milliseconds(4))) // 11122827For more information about formatting dates, see Date.FormatStyle.