dateComponents(in:from:)

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

iOS
8.0+
macOS
10.10+
tvOS
9.0+
watchOS
2.0+
func dateComponents(in timeZone: TimeZone, from date: Date) -> DateComponents

Parameters

timeZone

The TimeZone to use.

date

The Date to use.

Returns

All components, calculated using the Calendar and TimeZone.

The time zone overrides the time zone of the Calendar for the purposes of this calculation.