iOS 时间戳问题

2016-07-02  本文已影响110人  xiahua007

//转换为毫秒时间戳

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);

上一篇 下一篇

猜你喜欢

热点阅读