how can I compare two dates return number of days. Ex: Missing X days of the Cup. look my code.
NSDateFormatter *df = [[NSDateFormatter alloc]init];
[d
You can use next category:
@interface NSDate (Additions)
-(NSInteger)numberOfDaysUntilDay:(NSDate *)aDate;
-(NSInteger)numberOfHoursUntilDay:(NSDate *)aDate;
@end
@implementation NSDate (Additions)
const NSInteger secondPerMunite = 60;
const NSInteger munitePerHour = 60;
const NSInteger hourPerDay = 24;
-(NSInteger)numberOfDaysUntilDay:(NSDate *)aDate
{
NSInteger selfTimeInterval = [aDate timeIntervalSinceDate:self];
return abs(selfTimeInterval / (secondPerMunite * munitePerHour * hourPerDay));
}
-(NSInteger)numberOfHoursUntilDay:(NSDate *)aDate
{
NSInteger selfTimeInterval = [aDate timeIntervalSinceDate:self];
return abs(selfTimeInterval / (secondPerMunite * munitePerHour));
}
@end