开发者

Get actual date into seconds on iOS SDK

开发者 https://www.devze.com 2023-04-09 14:31 出处:网络
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?NSTi

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];  
}
0

精彩评论

暂无评论...
验证码 换一张
取 消