时间戳转日期字符串

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

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

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]];

你可能感兴趣的:(时间戳转日期字符串)