时间戳转时间字符串
//timeStr服务器给的时间戳字符串
NSDate * date = [NSDate dateWithTimeIntervalSince1970:[timeStr longLongValue]/1000.0];
NSDateFormatter *fmt = [[NSDateFormatter alloc] init];
[fmt setDateStyle:NSDateFormatterMediumStyle];
[fmt setTimeStyle:NSDateFormatterShortStyle];
fmt.dateFormat = @"yyyy-MM-dd HH:mm";
NSString *selfStr = [fmt stringFromDate:date];
return selfStr;
时间字符串转时间戳
//时间转时间戳的方法:
NSString *timeSp = [NSString stringWithFormat:@"现在时间的时间戳%ld", (long)[datenow timeIntervalSince1970]];
NSLog(@"timeSp:%@",timeSp); //时间戳的值