---
title: "components(in:from:)"
framework: foundation
role: symbol
role_heading: Instance Method
path: "foundation/nscalendar/components(in:from:)"
---

# components(in:from:)

Returns all the date components of a date, as if in a given time zone (instead of the receiving calendar’s time zone).

## Declaration

```swift
func components(in timezone: TimeZone, from date: Date) -> DateComponents
```

## Parameters

- `timezone`: The time zone to use when returning the components. This value overrides the time zone of the receiving NSCalendar.
- `date`: The date for which to perform the calculation.

## Return Value

Return Value An NSDateComponents object containing all the components from the given date, calculated using the given time zone.

## Discussion

Discussion If you want “date information in a given time zone” for the purpose to displaying it, you should use DateFormatter to format the date.

## See Also

### Extracting Components

- [date(_:matchesComponents:)](foundation/nscalendar/date(_:matchescomponents:).md)
- [component(_:from:)](foundation/nscalendar/component(_:from:).md)
- [components(_:from:)](foundation/nscalendar/components(_:from:).md)
- [components(_:from:to:options:)](foundation/nscalendar/components(_:from:to:options:)-84y5w.md)
- [components(_:from:to:options:)](foundation/nscalendar/components(_:from:to:options:)-49lo8.md)
- [getEra(_:year:month:day:from:)](foundation/nscalendar/getera(_:year:month:day:from:).md)
- [getEra(_:yearForWeekOfYear:weekOfYear:weekday:from:)](foundation/nscalendar/getera(_:yearforweekofyear:weekofyear:weekday:from:).md)
- [getHour(_:minute:second:nanosecond:from:)](foundation/nscalendar/gethour(_:minute:second:nanosecond:from:).md)
