Contents

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

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

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

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