Skip to content

Instance Method

dateComponents(_:from:to:)

iOS 8.0+ iPadOS 8.0+ Mac Catalyst 8.0+ macOS 10.10+ tvOS 9.0+ watchOS 2.0+
Returns the difference between two dates.
func dateComponents(_ components: Set<Calendar.Component>, from start: Date, to end: Date) -> DateComponents

Parameters

components

Which components to compare.

start

The starting date.

end

The ending date.

Return Value

The result of calculating the difference from start to end.