Get actual date into seconds on iOS SDK
I'm making an app where I need to get the actual date ([NSDate date开发者_JAVA技巧]
) into seconds since 1970 (timeIntervalSince1970
). But I don't manage to get it working, how should it be done?
NSTimeInterval seconds = [[NSDate date] timeIntervalSince1970]
Note that NSTimeInterval is actually a double
value, not an object.
double intrval=[[NSDate date] timeIntervalSince1970];
-(NSDate*)dateFromDouble:(double) intrval{
return [NSDate dateWithTimeIntervalSince1970:intrval];
}
精彩评论