Skip to content

StructureFoundationInternationalization

Date.FormatStyle.TimeStyle

iOS 15.0+ iPadOS 15.0+ Mac Catalyst 15.0+ macOS 12.0+ tvOS 15.0+ watchOS 8.0+
Type that defines time styles varied in length or components included.
struct TimeStyle

Overview

The exact format depends on the locale. Possible time styles include omitted, shortened, standard, and complete.

The following code sample shows a variety of time style format results using the en_US locale.

let meetingDate = Date()
meetingDate.formatted(date: .numeric, time: .omitted)
// 10/17/2020

meetingDate.formatted(date: .numeric, time: .shortened)
// 10/17/2020, 9:54 PM

meetingDate.formatted(date: .numeric, time: .standard)
// 10/17/2020, 9:54:29 PM

meetingDate.formatted(date: .numeric, time: .complete)
// 10/17/2020, 9:54:29 PM CDT

meetingDate.formatted()
// 10/17/2020, 9:54 PM

The default time style is shortened.

Topics

Initializers

Type Properties

Relationships

Conforms To

  • Swift.Decodable
  • Swift.Encodable
  • Swift.Equatable
  • Swift.Hashable
  • Swift.Sendable
  • Swift.SendableMetatype