Skip to content

Instantly share code, notes, and snippets.

@jazzedge
Last active November 30, 2017 16:38
Show Gist options
  • Select an option

  • Save jazzedge/95e96a6a4ce2753405e55ecc6ca64f2e to your computer and use it in GitHub Desktop.

Select an option

Save jazzedge/95e96a6a4ce2753405e55ecc6ca64f2e to your computer and use it in GitHub Desktop.
/**     Return the difrence of 2 dates in minutes        
- parameter fromDate: The first date for the comparison    
- parameter toDate: The second date for the comparison
*/
func dateDiffInMinutes(_ fromDate: Date, toDate: Date) -> Int {   
return (Calendar.current as NSCalendar).components(.minute, from: fromDate, to: toDate, options: NSCalendar.Options(rawValue: 0)).minute!
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment