【日期时间的计算NSDate Objective-C语言】

一、计算时间

1.比如,什么时候用这个计算时间呢

NSDate *date = [NSDate new];

NSLog(@“%@”,date);

我们知道,这个时候,它打印的时间是什么时间,是不是当前的时间啊,

我想得到,在当前系统时间之后5000秒以后的时间

5000秒以后,在当前时间的基础之上,

这时候,NSDate它提供了一个方法,是一个类方法啊,

+ (instancetype)dateWithTimeIntervalSinceNow:(NSTimeInterval)secs;

[NSDate dateWithTimeIntervalSinceNow:(NSTimeInterval)];

就是从现在开始,往后面数多少时间啊,参数什么类型的,NSTimeInterval类型的是不是,我们去看看这是什么东西啊,

typedef double

猜你喜欢

转载自blog.csdn.net/madoca/article/details/128124049