I have two NSDate objects: startDate and endDate, both are NSDate objects. I want to find the difference between these two dates. I know there is a resolved question about this already (Getting the difference between two NSDates in (months/days/hours/minutes/seconds)), but I want to know if there is a quicker way to do this (less execution code). Is that possible?
            Asked
            
        
        
            Active
            
        
            Viewed 3.2k times
        
    19
            
            
        - 
                    What do you mean by "quicker"? Faster execution or less code? [This answer](http://stackoverflow.com/a/27182410/1187415) to the referenced question solves it in a single statement, so what are you looking for? – Martin R Jul 24 '15 at 17:02
 
1 Answers
69
            Yes if you look at the second answer to your linked question you can do this: 
let interval = laterDate.timeIntervalSinceDate(earlierDate)
        pbush25
        
- 5,228
 - 2
 - 26
 - 35
 
- 
                    3
 - 
                    1@FedericoCapaldo check this: http://stackoverflow.com/questions/31132159/days-between-2-nsdates-in-a-calendar-year-swift – Ricardo Barroso Nov 11 '16 at 15:30
 - 
                    let interval = laterDate.timeIntervalSince(earlierDate as Date) : difference in seconds in Swift 3 – Alessandro Mattiuzzi May 04 '17 at 14:53
 - 
                    2