问题
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?
回答1:
Yes if you look at the second answer to your linked question you can do this:
let interval = laterDate.timeIntervalSinceDate(earlierDate)
来源:https://stackoverflow.com/questions/31615904/finding-the-difference-in-time-between-two-nsdates-swift