//转换为毫秒时间戳
UInt64 recordTime = [[NSDate date] timeIntervalSince1970]*1000;
//转换回来
NSTimeInterval time=recordTime/1000;
NSDate*detaildate=[NSDate dateWithTimeIntervalSince1970:time];
NSLog(@"这个有时差date:%@",[detaildate description]);
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc]init];
dateFormatter.dateFormat = @"YYYY-MM-dd HH:mm:ss";
NSString*currentDateStr = [dateFormatter stringFromDate:detaildate];
NSLog(@"转换没有时差:%@",currentDateStr);
网友评论