// 获取时间戳,并将时间戳转为北京时间
NSTimeInterval duration = [[NSDate date] timeIntervalSince1970];
NSString *timeString = [NSString stringWithFormat:@"%f", duration];
NSLog(@"====>返回URL时间戳 =>%@",timeString);
NSTimeInterval time=[timeString doubleValue] ;//传入的时间戳str如果是精确到毫秒的记得要/1000
NSDate *detailDate=[NSDate dateWithTimeIntervalSince1970:time];
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init]; //实例化一个NSDateFormatter对象
//设定时间格式,这里可以设置成自己需要的格式
[dateFormatter setDateFormat:@"yyyy-MM-dd HH:mm:ss SS"];
NSString *currentDateStr = [dateFormatter stringFromDate: detailDate];
NSLog(@"====>返回URL时间戳 => ===>%@",currentDateStr);
网友评论