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

# dateComponents(in:from:)

Returns all the date components of a date, as if in a given time zone (instead of the Calendar time zone).

## Declaration

```swift
func dateComponents(in timeZone: TimeZone, from date: Date) -> DateComponents
```

## Parameters

- `timeZone`: The TimeZone to use.
- `date`: The Date to use.

## Return Value

Return Value All components, calculated using the Calendar and TimeZone.

## Discussion

Discussion The time zone overrides the time zone of the Calendar for the purposes of this calculation. 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:)](foundation/calendar/datecomponents(_:from:).md)
- [dateComponents(_:from:to:)](foundation/calendar/datecomponents(_:from:to:)-2kcg.md)
- [dateComponents(_:from:to:)](foundation/calendar/datecomponents(_:from:to:)-5g20t.md)
- [Calendar.Component](foundation/calendar/component.md)
