Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Array of dates between two dates

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 544
    Comment on it

    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)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: