时间戳转时间

     NSString *curren = [self timeWithTimeIntervalString:time];

- (NSString *)timeWithTimeIntervalString:(NSString *)timeString

{

    NSTimeInterval time=[timeString doubleValue]+28800;//因为时差问题要加8小时 == 28800 sec

    NSDate *detaildate=[NSDate dateWithTimeIntervalSince1970:time];

    NSLog(@"date:%@",[detaildate description]);

    //实例化一个NSDateFormatter对象

    NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];

    //设定时间格式,这里可以设置成自己需要的格式

    [dateFormatter setDateFormat:@"yyyy-MM-dd HH:mm:ss"];

    NSString *currentDateStr = [dateFormatter stringFromDate: detaildate];

    return currentDateStr;

}

原文地址:https://www.cnblogs.com/liaolijun/p/6767451.html