19

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?

Community
  • 1
  • 1
ButtonMasterBot
  • 317
  • 2
  • 5
  • 14
  • 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 Answers1

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