Contents

Date.FormatStyle.Symbol.Second

A type that specifies the format for the seconds in a date format style.

Declaration

struct Second

Overview

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 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()) // 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.

Topics

Modifying a Second

Comparing Seconds

Type Properties

See Also

Modifying Date Style Format Symbols