您的位置:首页 > 其它

时间戳转字符串,单独写了一个类方法。转换方便。

2016-11-12 10:17 190 查看
类方法:

//时间戳转字符串

+(NSString *)getTimeString:(long int)time;  

//时间戳转字符串

+(NSString *)getTimeString:(long int)time

{

    NSTimeInterval timeInterval = time + 28800;

    

    NSDate * date = [NSDate dateWithTimeIntervalSince1970:timeInterval];

    

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

    

    //设定时间格式,这里可以设置成自己需要的格式

    

    [dateFormatter setDateFormat:@"yyyy-MM-dd HH:mm"];

    

    NSString * dateStr = [dateFormatter stringFromDate:date];

    

    return dateStr;

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: