timeIntervalSinceDate:
2つの時間間隔を返します
-(NSTimeInterval)timeIntervalSinceDate:(NSDate *)anotherDate:
解説
2つの時間間隔を返します。
anotherDateの方が遅ければ、結果はマイナスで返されます。
返り値
( NSTimeInterval )
時間間隔
引数
( NSDate * )anotherDate
時間
フレームワーク
Foundation
クラス
NSDate
Instance Methods
使用可能
10.0
参照
- timeIntervalSince1970
- timeIntervalSinceNow
- timeIntervalSinceReferenceDate
例文
#import "MyObject.h" @implementation MyObject - (IBAction)myAction:(id)sender { NSDate *theDate1 = [NSDate dateWithString:@"2002-12-03 04:56:00 +0900"]; NSDate *theDate2 = [NSDate dateWithString:@"2002-12-04 04:56:00 +0900"]; NSLog([NSString stringWithFormat:@"%.1f",[theDate1 timeIntervalSinceDate:theDate2]]);} @end