NSDate*senddate = [NSDatedate];
NSLog(@"date1時(shí)間戳= %ld",time(NULL));
NSString*date2 = [NSStringstringWithFormat:@"%ld", (long)[senddatetimeIntervalSince1970]];
NSLog(@"date2時(shí)間戳= %@",date2);
NSDateFormatter*dateformatter = [[NSDateFormatteralloc]init];
[dateformattersetDateFormat:@"YYYY-MM-dd HH:mm:ss"];
NSString*date1 = [dateformatterstringFromDate:senddate];
NSLog(@"獲取當(dāng)前時(shí)間= %@",date1);
//時(shí)間戳轉(zhuǎn)時(shí)間
NSDate*confromTimesp = [NSDatedateWithTimeIntervalSince1970:[senddatetimeIntervalSince1970]];
NSString*confromTimespStr = [dateformatterstringFromDate:confromTimesp];
NSLog(@"時(shí)間戳轉(zhuǎn)時(shí)間= %@",confromTimespStr);
// 兩個(gè)時(shí)間戳的間隔返回的是秒
NSTimeIntervaltime = [nowtimeIntervalSinceDate:oldDate];
NSLog(@"time:%f",time/60/60/24);
原文:http://blog.csdn.net/u014286994/article/details/50687440