Skip to content

StructureFoundationInternationalization

Date.FormatStyle.DateStyle

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

Overview

The exact format depends on the locale. Possible values of date style include omitted, numeric, abbreviated, long, and complete.

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

let meetingDate = Date()
meetingDate.formatted(date: .omitted, time: .standard)
// 9:42:14 AM

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

meetingDate.formatted(date: .abbreviated, time: .omitted)
// Oct 17, 2020

meetingDate.formatted(date: .long, time: .omitted)
// October 17, 2020

meetingDate.formatted(date: .complete, time: .omitted)
// Saturday, October 17, 2020

meetingDate.formatted()
// 10/17/2020, 9:42 AM

The default date style is numeric.

Topics

Initializers

Type Properties

Relationships

Conforms To

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