//endTime是要与当前时间做比较的另一个时间
- (void)keyLostTimeWithEndTime:(NSString *)endTime
{
//当前时间
NSDate* dat = [NSDate date];
NSTimeInterval a = [dat timeIntervalSince1970]*1000;
NSString *timeString = [NSString stringWithFormat:@"%f", a];
long long nowTime = [timeString longLongValue];
long long end = [endTime longLongValue];
//使用当前时间来判断还剩余多少天
long long time = (end -nowTime)/1000/60/60/24;
//获取当前时间戳
if (end-nowTime >= 0) {
if (time <= 1) {
self.daysLbl.text = @"今日";
self.daysDeatilsLbl.text = @"";
}else{
self.daysLbl.text = [NSString stringWithFormat:@"%ld天", (long)time];
self.daysDeatilsLbl.text = @"距离";
}
}else if(end-nowTime < 0){
long long time = (nowTime - end)/1000/60/60/24;
if (time == 0) {
self.daysLbl.text = @"今日";
self.daysDeatilsLbl.text = @"";
}else{
self.daysLbl.text = [NSString stringWithFormat:@"%ld天", (long)time];
self.daysDeatilsLbl.text = @"逾期";
}
}
}
网友评论