Date.FormatStyle.Symbol.Second
A type that specifies the format for the seconds in a date format style.
Declaration
struct SecondOverview
The type Date.FormatStyle.Symbol.Second includes static factory variables that create custom Date.FormatStyle.Symbol.Second objects:
Factory variable | Description |
|---|---|
The minimum number of digits that represents the numeric second. For example, | |
Two-digit numeric second, zero-padded if necessary. For example, |
To customize the second format in a string representation of a Date, use second(_:). The following example shows a variety of Date.FormatStyle.Symbol.Second format styles applied to a date.
let meetingDate = Date() // Feb 9, 2021 at 3:05 PM
meetingDate.formatted(Date.FormatStyle().second(.defaultDigits)) // 5
meetingDate.formatted(Date.FormatStyle().second(.twoDigits)) // 05
meetingDate.formatted(Date.FormatStyle().second()) // 5If no format is specified as a parameter, the defaultDigits static variable is the default format.
For more information about formatting dates, see the Date.FormatStyle.
Topics
Modifying a Second
Comparing Seconds
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.MonthDate.FormatStyle.Symbol.QuarterDate.FormatStyle.Symbol.SecondFractionDate.FormatStyle.Symbol.StandaloneMonthDate.FormatStyle.Symbol.StandaloneQuarterDate.FormatStyle.Symbol.StandaloneWeekdayDate.FormatStyle.Symbol.TimeZoneDate.FormatStyle.Symbol.VerbatimHour