How to do date subtraction in ios get 15 days ago from today date

    To get 15 days earlier from today's date
    NSDate *todayDate = [NSDate date];

    NSDateComponents *dc = [[NSDateComponents alloc] init];
    [dc setDay:-15];

    NSDate *fiftenDaysAgo = [[NSCalendar currentCalendar] dateByAddingComponents:dc toDate:todayDate options:0];


    NSLog(@"15 Days Ago: %@", fiftenDaysAgo);
    5
    Average: 5 (1 vote)