Hello Friends,
To create an array of dates between two dates you may use the following code:
1.Create an NSMutableArray
NSMutableArray *datesArray = [NSMutableArray new];
2.Set the date formatter according to your requirement.
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"MM-dd-yyyy"];
[dateFormatter setTimeZone:[NSTimeZone timeZoneWithName:@"UTC"]];
NSCalendar *gregorianCalendar = [[NSCalendar alloc] initWithCalendarIdentifier: NSCalendarIdentifierGregorian];
[gregorianCalendar setTimeZone:[NSTimeZone systemTimeZone]];
3.Create two date variables for minimum and maximum date
NSDate *minDate = [dateFormatter dateFromString:@"MinimumDate"];
NSDate *maxDate = [dateFormatter dateFromString:@"MaximumDate"];
4. Create a copy of minimum Date .
NSMutableArray *datesArray = [NSMutableArray new];
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"MM-dd-yyyy"];
[dateFormatter setTimeZone:[NSTimeZone timeZoneWithName:@"UTC"]];
NSCalendar *gregorianCalendar = [[NSCalendar alloc] initWithCalendarIdentifier: NSCalendarIdentifierGregorian];
[gregorianCalendar setTimeZone:[NSTimeZone systemTimeZone]];
0 Comment(s)