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

+ (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根据时间戳获取时间字符串)