---
title: iso8601
framework: swift
role: symbol
role_heading: Type Property
path: swift/regexcomponent/iso8601
---

# iso8601

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

## Declaration

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

## Discussion

Discussion This property matches date substrings in accordance with the formatting of Foundation’s Date.ISO8601FormatStyle. This matches the default format of the ISO 8601 format style. The following example creates a 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

## See Also

### Matching dates and times

- [date(_:locale:timeZone:calendar:)](swift/regexcomponent/date(_:locale:timezone:calendar:).md)
- [date(format:locale:timeZone:calendar:twoDigitStartDate:)](swift/regexcomponent/date(format:locale:timezone:calendar:twodigitstartdate:).md)
- [dateTime(date:time:locale:timeZone:calendar:)](swift/regexcomponent/datetime(date:time:locale:timezone:calendar:).md)
- [iso8601Date(timeZone:dateSeparator:)](swift/regexcomponent/iso8601date(timezone:dateseparator:).md)
- [iso8601(timeZone:includingFractionalSeconds:dateSeparator:dateTimeSeparator:timeSeparator:)](swift/regexcomponent/iso8601(timezone:includingfractionalseconds:dateseparator:datetimeseparator:timeseparator:).md)
- [iso8601WithTimeZone(includingFractionalSeconds:dateSeparator:dateTimeSeparator:timeSeparator:timeZoneSeparator:)](swift/regexcomponent/iso8601withtimezone(includingfractionalseconds:dateseparator:datetimeseparator:timeseparator:timezoneseparator:).md)
