---
title: "iso8601DateComponents(timeZone:dateSeparator:)"
framework: swift
role: symbol
role_heading: Type Method
path: "swift/regexcomponent/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.

## Declaration

```swift
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

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