macOS/iOS API解説

iOS , Mac アプリケーション開発のために使われる主要フレームワークの日本語情報です。2010年代に書かれた内容です。今後更新はありません。

目次

timeIntervalSince1970

1970年1月1日0時0分0秒から現在の日付時間の間隔を返します

解説

グリニッジ標準時(GMT)の1970年1月1日0時0分0秒から現在の日付時間の間隔(NSTimeInterval)を返します。
未来の日付けはプラス、過去の日付けはマイナスをセットします。
BSDシステム関数は1970年から始まるので、そのときに便利

返り値

( NSTimeInterval )

時間間隔

引数

クラス

NSDate

Instance Methods

使用可能

10.0

参照

- timeIntervalSinceDate:
- timeIntervalSinceNow
- timeIntervalSinceReferenceDate

例文

#import "MyObject.h"

@implementation MyObject

- (IBAction)myAction:(id)sender
{
NSDate *theDate1 = [NSDate dateWithString:@"2002-12-03 04:56:00 +0900"];
NSLog([NSString stringWithFormat:@"%.1f",[theDate1 timeIntervalSince1970]]);
 }
@end