美文网首页
IOS根据时间戳获取时间字符串

IOS根据时间戳获取时间字符串

作者: 蜗牛1992 | 来源:发表于2016-09-03 21:51 被阅读54次
+ (NSString *)GetCurrentTimeDate:(long64)iDenty{
    
    NSDate *pDate = [NSDate dateWithTimeIntervalSince1970:(iDenty)/1000];
    NSDateFormatter *pFormatter = [[NSDateFormatter alloc]init];
    [pFormatter setDateFormat:@"yyyy-MM-dd HH:mm"];
   return [pFormatter stringFromDate:pDate];
}

//精确到秒
+ (NSString *)GetCurrentTimeDate2:(long64)iDenty{
    NSDate *pDate = [NSDate dateWithTimeIntervalSince1970:(iDenty)/1000];
    NSDateFormatter *pFormatter = [[NSDateFormatter alloc]init];
    [pFormatter setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
    return [pFormatter stringFromDate:pDate];
}

相关文章

网友评论

      本文标题:IOS根据时间戳获取时间字符串

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