<!--
{
  "availability" : [
    "iOS: 16.0.0 -",
    "iPadOS: 16.0.0 -",
    "macCatalyst: 16.0.0 -",
    "macOS: 13.0.0 -",
    "tvOS: 16.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 9.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Swift",
  "identifier" : "/documentation/Swift/RegexComponent/iso8601",
  "metadataVersion" : "0.1.0",
  "role" : "Type Property",
  "symbol" : {
    "kind" : "Type Property",
    "modules" : [
      "Swift"
    ],
    "preciseIdentifier" : "s:17_StringProcessing14RegexComponentP10FoundationAD4DateV18ISO8601FormatStyleVRszrlE7iso8601AHvpZ"
  },
  "title" : "iso8601"
}
-->

# iso8601

A regex component that matches a default ISO 8601-formatted date string, capturing it as a Foundation date.

```
static var iso8601: Date.ISO8601FormatStyle { get }
```

## Discussion

This property matches date substrings in accordance with the formatting of Foundation’s <doc://com.apple.documentation/documentation/Foundation/Date/ISO8601FormatStyle>. This matches the default format of the ISO 8601 format style.

The following example creates a [`Regex`](/documentation/Swift/Regex) that matches a date formatted with the base ISO 8601 format. It then matches this regex against a source string containing a date and time with this format (using the default UTC time zone, which `Z` indicates), some whitespace, a substring, more whitespace, and a currency value.

```
let iso860Source = "2022-07-14T21:10:15Z   Lemon-lime slushie      $1.99"
let matcher = Regex {
    Capture {
        One(.iso8601)
    }
    OneOrMore(.horizontalWhitespace)
    OneOrMore(.any)
    OneOrMore(.horizontalWhitespace)
    One(.localizedCurrency(code:Locale.Currency("USD"),
                           locale:Locale(identifier: "en_US")))
}
let match = iso860Source.firstMatch(of: matcher)
let date = match?.1 // date == Jul 14, 2022 at 2:10 PM PST
```

---

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)