[Solved] How to check if 2 Dates have a difference of 30days? [duplicate]


You can convert both dates to seconds with timeIntervalSince1970 and then check if difference is bigger than 2592000 (30*24*60*60 which is 30 days * 24 hours * 60 minutes * 60 seconds).

NSTimeInterval difference = [date1 timeIntervalSince1970] - [date2 timeIntervalSince1970];

if(difference >2592000)
{
 //do your stuff here
}

EDIT:
For more compact version you can use – (NSTimeInterval)timeIntervalSinceDate:(NSDate *)anotherDate

NSTimeInterval difference = [date1 timeIntervalSinceDate:date2];
if(difference >2592000)
{
    //do your stuff here
}

5

solved How to check if 2 Dates have a difference of 30days? [duplicate]