---
title: "dateComponents(_:from:)"
framework: foundation
role: symbol
role_heading: Instance Method
path: "foundation/calendar/datecomponents(_:from:)"
---

# dateComponents(_:from:)

Returns all the date components of a date, using the calendar time zone.

## Declaration

```swift
func dateComponents(_ components: Set<Calendar.Component>, from date: Date) -> DateComponents
```

## Parameters

- `components`: The components to return.
- `date`: The Date to use.

## Return Value

Return Value The date components of the specified date.

## Discussion

Discussion note: If you want “date information in a given time zone” in order to display it, you should use DateFormatter to format the date.

## See Also

### Extracting Components

- [date(_:matchesComponents:)](foundation/calendar/date(_:matchescomponents:).md)
- [component(_:from:)](foundation/calendar/component(_:from:).md)
- [dateComponents(_:from:to:)](foundation/calendar/datecomponents(_:from:to:)-2kcg.md)
- [dateComponents(_:from:to:)](foundation/calendar/datecomponents(_:from:to:)-5g20t.md)
- [dateComponents(in:from:)](foundation/calendar/datecomponents(in:from:).md)
- [Calendar.Component](foundation/calendar/component.md)
