NSDate *timestamp = [NSDatedateWithTimeIntervalSince1970:[@"1231231231"integerValue]];
NSDateFormatter *formatter = [[NSDateFormatteralloc]init];
NSTimeZone *timeZone = [NSTimeZonelocalTimeZone];
[formatter setTimeZone:timeZone];
[formatter setDateFormat:@"yyyy-MM-dd"];
dateLable.text = [NSStringstringWithFormat:@"日期:%@",[formatterstringFromDate:timestamp]];
把时间转化为时间戳:
NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
[formatter setDateFormat:@"YYYY-MM-dd HH:mm:ss"];
[formatter setTimeZone:[NSTimeZone localTimeZone]];
NSString *expireDatetime = [myIpa.ipaExpireDatetime substringToIndex:19];
NSDate *date = [formatter dateFromString:expireDatetime];
NSDate *datenow = [NSDate date];
NSInteger time = (NSInteger)[date timeIntervalSinceDate:datenow];
NSString *resultTime;
if((time/60/60)<10)
resultTime = [NSString stringWithFormat:@"剩余:0%d:%d:%d",time/60/60,(time/60)%60,time%60];
else
resultTime = [NSString stringWithFormat:@"剩余:%d:%d:%d",time/60/60,(time/60)%60,time%60];
cell.cellTime.text = resultTime;