您的位置:首页 > 其它

计算两个NSDate之间的间隔

2012-11-15 14:18 274 查看
需要计算两个时间(NSDate类型)的时间间隔时,用下面函数

- (NSTimeInterval)timeIntervalSinceDate:(NSDate *)anotherDate

Returns the interval between the receiver and another given date.
- (NSTimeInterval)timeIntervalSinceDate:(NSDate *)anotherDate
 
NSTimeInterval返回的是一个double值,单位是秒

– timeIntervalSince1970
 计算从1970年以来经过的timeInterval

– timeIntervalSinceNow
 计算从现在
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: