dateComponents(_:from:to:)

Returns the difference between two dates.

iOS
8.0+
macOS
10.10+
tvOS
9.0+
watchOS
2.0+
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.

Returns

The result of calculating the difference from start to end.