<!--
{
  "availability" : [
    "iOS: 15.0.0 -",
    "iPadOS: 15.0.0 -",
    "macCatalyst: 15.0.0 -",
    "macOS: 12.0.0 -",
    "tvOS: 15.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 8.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/Date/ISO8601FormatStyle",
  "metadataVersion" : "0.1.0",
  "role" : "Structure",
  "symbol" : {
    "kind" : "Structure",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "s:10Foundation4DateV18ISO8601FormatStyleV"
  },
  "title" : "Date.ISO8601FormatStyle"
}
-->

# Date.ISO8601FormatStyle

A type that converts between dates and their ISO-8601 string representations.

```
struct ISO8601FormatStyle
```

## Overview

The [`Date.ISO8601FormatStyle`](/documentation/Foundation/Date/ISO8601FormatStyle) type generates and parses string representations of dates following the [ISO-8601](https://www.iso.org/iso-8601-date-and-time-format.html) standard, like `2024-04-01T12:34:56.789Z`. Use this type to create ISO-8601 representations of dates and create dates from text strings in ISO 8601 format. For other formatting conventions, like human-readable, localized date formats, use [`Date.FormatStyle`](/documentation/Foundation/Date/FormatStyle).

Instance modifier methods applied to an ISO-8601 format style customize the formatted output, as the following example illustrates.

```swift
let now = Date()
print(now.formatted(Date.ISO8601FormatStyle().dateSeparator(.dash)))
// 2021-06-21T211015Z
```

Use the static factory property `FormatStyle/iso8601` to create an instance of [`Date.ISO8601FormatStyle`](/documentation/Foundation/Date/ISO8601FormatStyle). Then apply instance modifier methods to customize the format, as in the example below.

```swift
let meetNow = Date()
let formatted = meetNow.formatted(.iso8601
    .year()
    .month()
    .day()
    .timeZone(separator: .omitted)
    .time(includingFractionalSeconds: true)
    .timeSeparator(.colon)
) // "2022-06-10T12:34:56.789Z"
```

## Topics

### Creating an ISO 8601 Format Style

[`init(dateSeparator:dateTimeSeparator:timeZone:)`](/documentation/Foundation/Date/ISO8601FormatStyle/init(dateSeparator:dateTimeSeparator:timeZone:))

Creates an instance using the provided date separator, date and time components separator, and time zone.

### Modifying an ISO 8601 Format Style

[`dateSeparator`](/documentation/Foundation/Date/ISO8601FormatStyle/dateSeparator-swift.property)

The character used to separate the components of a date.

[`dateTimeSeparator`](/documentation/Foundation/Date/ISO8601FormatStyle/dateTimeSeparator-swift.property)

The character used to separate the date and time components of an ISO 8601 string representation of a date.

[`timeZone`](/documentation/Foundation/Date/ISO8601FormatStyle/timeZone)

The time zone used to create and parse date representations.

[`dateTimeSeparator(_:)`](/documentation/Foundation/Date/ISO8601FormatStyle/dateTimeSeparator(_:))

Sets the character that specifies the date and time components.

### Modifying Dates in an ISO 8601 Format Style

[`dateSeparator(_:)`](/documentation/Foundation/Date/ISO8601FormatStyle/dateSeparator(_:))

Modifies the ISO 8601 date format style to use the specified date separator.

[`year()`](/documentation/Foundation/Date/ISO8601FormatStyle/year())

Modifies the ISO 8601 date format style to include the year in the formatted output.

[`month()`](/documentation/Foundation/Date/ISO8601FormatStyle/month())

Modifies the ISO 8601 date format style to include the month in the formatted output.

[`weekOfYear()`](/documentation/Foundation/Date/ISO8601FormatStyle/weekOfYear())

Modifies the ISO 8601 date format style to include the week of the year in the formatted output.

[`day()`](/documentation/Foundation/Date/ISO8601FormatStyle/day())

Modifies the ISO 8601 date format style to include the day in the formatted output.

### Modifying Times in an ISO 8601 Format Style

[`time(includingFractionalSeconds:)`](/documentation/Foundation/Date/ISO8601FormatStyle/time(includingFractionalSeconds:))

Modifies the ISO 8601 date format style to include the time in the formatted output.

[`timeSeparator(_:)`](/documentation/Foundation/Date/ISO8601FormatStyle/timeSeparator(_:))

Modifies the ISO 8601 date format style to use the specified time separator.

[`timeZone(separator:)`](/documentation/Foundation/Date/ISO8601FormatStyle/timeZone(separator:))

Modifies the ISO 8601 date format style to include the time zone in the formatted output.

[`timeZoneSeparator(_:)`](/documentation/Foundation/Date/ISO8601FormatStyle/timeZoneSeparator(_:))

Modifies the ISO 8601 date format style to use the specified time zone separator.

### Parsing an ISO 8601 Format Style

[`parse(_:)`](/documentation/Foundation/Date/ISO8601FormatStyle/parse(_:))

Parses a string into a date.

[`parseStrategy`](/documentation/Foundation/Date/ISO8601FormatStyle/parseStrategy)

The strategy used to parse a string into a date.

### Applying an ISO 8601 Format Style

[`format(_:)`](/documentation/Foundation/Date/ISO8601FormatStyle/format(_:))

Creates a locale-aware ISO 8601 string representation from a date value.

### Comparing ISO 8601 Format Styles

[`==(_:_:)`](/documentation/Foundation/Date/==(_:_:))

Returns true if the two `Date` values represent the same point in time.

### Supporting Types

[`Date.ISO8601FormatStyle.DateSeparator`](/documentation/Foundation/Date/ISO8601FormatStyle/DateSeparator-swift.enum)

A type describing the character separating year, month, and day components of a date in an ISO 8601 date format.

[`Date.ISO8601FormatStyle.DateTimeSeparator`](/documentation/Foundation/Date/ISO8601FormatStyle/DateTimeSeparator-swift.enum)

Type describing the character separating the date and time components of a date in an ISO 8601 date format.

[`Date.ISO8601FormatStyle.TimeSeparator`](/documentation/Foundation/Date/ISO8601FormatStyle/TimeSeparator-swift.enum)

Type describing the character separating the time components of a date in an ISO 8601 date format.

[`Date.ISO8601FormatStyle.TimeZoneSeparator`](/documentation/Foundation/Date/ISO8601FormatStyle/TimeZoneSeparator-swift.enum)

A type describing the character separating the time and time zone of a date in an ISO 8601 date format.

### Supporting Type Methods



---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)