jazzedge
11/30/2017 - 1:27 PM

Swift - Dates - Get Minutes between 2 Dates

/**     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! 
}