iOS将后台传的秒数转换为日期格式

- (NSString *)returndate:(NSNumber *)num{

NSString *str1=[NSString stringWithFormat:@"%@",num];

int x=[[str1 substringToIndex:10] intValue];

NSDate  *date1 = [NSDate dateWithTimeIntervalSince1970:x];

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

[dateformatter setDateFormat:@"yyyy-MM-dd hh:mm"];

return [dateformatter stringFromDate:date1];

}

你可能感兴趣的:(iOS将后台传的秒数转换为日期格式)