<!--
{
  "availability" : [
    "iOS: 26.0.0 -",
    "iPadOS: 26.0.0 -",
    "macCatalyst: 26.0.0 -",
    "macOS: 26.0.0 -",
    "tvOS: 26.0.0 -",
    "visionOS: 26.0.0 -",
    "watchOS: 26.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Swift",
  "identifier" : "/documentation/Swift/RegexComponent/iso8601DateComponents(timeZone:dateSeparator:)",
  "metadataVersion" : "0.1.0",
  "role" : "Type Method",
  "symbol" : {
    "kind" : "Type Method",
    "modules" : [
      "Swift"
    ],
    "preciseIdentifier" : "s:17_StringProcessing14RegexComponentP10FoundationAD14DateComponentsV18ISO8601FormatStyleVRszrlE07iso8601fG08timeZone13dateSeparatorAhD04TimeM0V_AD0F0VAGV0fO0OtFZ"
  },
  "title" : "iso8601DateComponents(timeZone:dateSeparator:)"
}
-->

# iso8601DateComponents(timeZone:dateSeparator:)

Creates a regex component to match an ISO 8601 date string, such as “2015-11-14”, and capture the string as a `DateComponents`. The captured `DateComponents` would be at midnight in the specified `timeZone`.

```
static func iso8601DateComponents(timeZone: TimeZone, dateSeparator: Date.ISO8601FormatStyle.DateSeparator = .dash) -> Self
```

## Parameters

`timeZone`

The time zone to create the captured `Date` with.

`dateSeparator`

The separator between date components.

## Return Value

A `RegexComponent` to match an ISO 8601 date string, not any time zone that may be in the string.

---

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)