- (NSString *)ConvertStrToTime:(NSString *)timeStr
{
long long time=[timeStr longLongValue];
// 如果服务器返回的是13位字符串,需要除以1000,否则显示不正确(13位其实代表的是毫秒,需要除以1000)
// long long time=[timeStr longLongValue] / 1000;
NSDate *date = [[NSDate alloc]initWithTimeIntervalSince1970:time];
NSDateFormatter *formatter = [[NSDateFormatter alloc]init];
[formatter setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
NSString*timeString=[formatter stringFromDate:date];
return timeString;
}
网友评论