转化为的格式例:2015/01/23 11:54 (格式是可以自己修改的,改成自己需要的样式就好了)
- (NSString *)SetTime:(NSString *)time {
NSDateFormatter*formatter = [[NSDateFormatter alloc]init];
[formatter setDateStyle:NSDateFormatterMediumStyle];
[formatter setTimeStyle:NSDateFormatterShortStyle];
[formatter setDateFormat:@"yyyy/MM/dd hh:mm"];(这里是设置时间格式)
int timeval = [time intValue];
NSDate *confromTimesp = [NSDate dateWithTimeIntervalSince1970:timeval];
NSString *confromTimespStr = [formatter stringFromDate:confromTimesp];
return confromTimespStr;
}
time就是传入的时间戳 返回的是你设定格式的时间
网友评论