时间戳转日期字符串

作者: 强强刘 | 来源:发表于2016-10-21 11:33 被阅读94次

时间戳转成一定格式的日期字符串;

应用场景:开发中经常遇到服务端返回数据是时间戳的场景,而在页面展示的时候确实需要显示常见的日期格式;

NSTimeInterval interval=[@"1477016421743" longValue] / 1000.0;

NSDate *date = [NSDate dateWithTimeIntervalSince1970:interval];

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

[objDateformat setDateFormat:@"yyyy-MM-dd"];

NSString *timeStr = [NSString stringWithFormat:@"%@",[objDateformat stringFromDate: date]];

相关文章

网友评论

本文标题:时间戳转日期字符串

本文链接:https://www.haomeiwen.com/subject/nyaquttx.html