So i'm looking to create an object for each month in-between two dates..
Start: 01/08/2012
End: 02/10/2012
would be two months so id like to list out:
01/09/2012 01/10/2012
..ready for me to create an NSDate for each of those to push to Parse(.com)..
Here's what i've got so far:
NSString *start = @"2010-09-15";
NSString *end = @"2011-07-15";
NSDateFormatter *f = [[NSDateFormatter alloc] init];
[f setDateFormat:@"yyyy-MM-dd"];
NSDate *startDate = [f dateFromString:start];
NSDate *endDate = [f dateFromString:end];
NSCalendar *gregorianCalendar = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];
NSDateComponents *components = [gregorianCalendar components:NSMonthCalendarUnit
fromDate:startDate
toDate:endDate
options:0];
int i=0;
for (i = 0; i < [components month]; i++)
{
NSLog(@"%i", i+1);
NSDateFormatter *df = [NSDateFormatter new];
// change locale if the standard is not what you want
NSArray *monthNames = [df standaloneMonthSymbols];
NSString *monthName = [monthNames objectAtIndex:(i)];
NSLog(@"Month name: %@", monthName);
}
Thanks for your help!