Finding the difference in time between two NSDates Swift [duplicate]

怎甘沉沦 提交于 2019-12-04 17:10:16

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!