当前日期不应该在开始日期去结束日期后,但它可以等于开始日期或结束日期。检查今天的日期开始日期和结束日期之间落在
我该如何修改代码?
for(AllBookings *book in bookarray)
{
NSString *startdte = book.StartDate; //taking start date from array
NSString *enddte = book.EndDate;
NSDate *start = [self getDateFromJSON:startdte];
NSDate *end = [self getDateFromJSON:enddte];
NSDate *now = [NSDate date];
NSTimeInterval fromTime = [start timeIntervalSinceReferenceDate];
NSTimeInterval toTime = [end timeIntervalSinceReferenceDate];
NSTimeInterval currTime = [[NSDate date] timeIntervalSinceReferenceDate];
if((fromTime<currTime) && (toTime>=currTime))//checking if currnt is in btw strt n end
{
success = TRUE;
break;
}
else {
success = FALSE;
}
}
在这里检查你发现许多完全相同的问题。 –
检查此链接http://stackoverflow.com/questions/6112075/ios-compare-two-dates – Durgaprasad