我正在从数据库表中获取日期。我从数据库中获取到期日期,直到这里一切正常现在我必须将此到期日期与当前日期进行比较,如果当前日期大于或等于来自数据库的到期日期然后我想打印字符串单元格为“到期”
我尝试了很多,但我的问题是字符串值显示了一些 ware 而他们没有显示一些 ware 我的代码中的错误是什么。
NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init];
[dateFormat setDateFormat:@"dd/MM/yyyy"];
NSString* duedate = [dateFormat stringFromDate:taskobject.DueDate];
NSDate *currentdate;
currentdate=[NSDate date];
//NSDateFormatter *dateFormat1 = [[NSDateFormatter alloc] init];
//[dateFormat1 setDateFormat:@"dd/MM/yyyy"];
NSString* duedate1 = [dateFormat stringFromDate:currentdate];
if ([currentdate compare:taskobject.DueDate]!=NSOrderedDescending) {
DateLable.text=@"Due";
DateLable.textColor=[UIColor redColor];
}
else{
DateLable.text=duedate;
DateLable.textColor=[UIColor blackColor];
}