A type that specifies the format for the seconds in a date format style.
The type ``Date/FormatStyle/Symbol/Second`` includes static factory variables that create custom ``Date/FormatStyle/Symbol/Second`` objects:
|Factory variable|Description|
|---|---|
| ``defaultDigits`` | The minimum number of digits that represents the numeric second. For example, `1`, `18`. |
| ``twoDigits`` | Two-digit numeric second, zero-padded if necessary. For example, `01`, `18`. |
To customize the second format in a string representation of a `Date`, use ``Date/FormatStyle/second(_:)``. The following example shows a variety of ``Date/FormatStyle/Symbol/Second`` format styles applied to a date.
```swift
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()) // 5
```
If 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``.
Members (3)
get · iOS 15.0+
defaultDigits
TypeScript
static get defaultDigits(): Date_FormatStyle_Symbol_Second
Swift declaration
static var defaultDigits: Date.FormatStyle.Symbol.Second { get }
Minimum digits to show the numeric second. Truncated, not rounded. For example, `8`, `12`.
get · iOS 18.0+
omitted
TypeScript
static get omitted(): Date_FormatStyle_Symbol_Second
Swift declaration
static let omitted: Date.FormatStyle.Symbol.Second
The option for not including the symbol in the formatted output.
get · iOS 15.0+
twoDigits
TypeScript
static get twoDigits(): Date_FormatStyle_Symbol_Second
Swift declaration
static var twoDigits: Date.FormatStyle.Symbol.Second { get }
Two digits numeric, zero padded if needed, not rounded. For example, `08`, `12`.