Skip to content

Instance Method

dateComponents(_:from:)

iOS 8.0+ iPadOS 8.0+ Mac Catalyst 8.0+ macOS 10.10+ tvOS 9.0+ watchOS 2.0+
Returns all the date components of a date, using the calendar time zone.
func dateComponents(_ components: Set<Calendar.Component>, from date: Date) -> DateComponents

Parameters

date

The Date to use.

Return Value

The date components of the specified date.

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.