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
componentsWhich components to compare.
startThe starting date.
endThe ending date.
Return Value
The result of calculating the difference from start to end.