I am receiving time in seconds from server and then i am converting tjose seconds into month using this code:
NSDateFormatter * dateFormatter=[[[NSDateFormatte
You can compare for the difference between two dates as timestamps
NSDateFormatter * dateFormatter=[[[NSDateFormatter alloc]init]autorelease];
dateFormatter setDateFormat:@"MMM"];
NSString* monthName = [dateFormatter stringFromDate:[NSDate dateWithTimeIntervalSince1970:newTimestamp]]
NSTimeInterval month = 60.0 * 60.0 * 24.0 * 31.0; //seconds * minutes * hours * days ~ month
NSTimeInterval tempTimestamp = oldTimestamp;
while(tempTimestamp - newTimestamp) > month){
//more than a month difference -> add a month
NSString* tempMonthName = [dateFormatter stringFromDate:[NSDate dateWithTimeIntervalSince1970:tempTimestamp]];
if(![monthName isEqualTo:newMonthName]){
//do whatever you need with the additional month name...
}
tempTimestamp += month;
}
Hope it will help.
Cheers...