Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6835275
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T23:12:47+00:00 2026-05-26T23:12:47+00:00

I want add days to an NSDate . The approach below is not working.

  • 0

I want add days to an NSDate. The approach below is not working. Can someone help me fix this issue?

int daysToAdd=[[appDlegateObj.selectedSkuData 
                                    objectForKey:@"Release Time"] intValue];

NSTimeInterval secondsForFollowOn=daysToAdd*24*60*60;

NSString *dateStr=[contentDic objectForKey:@"Date"];

NSDateFormatter *dateFormatter=[[NSDateFormatter alloc]init];

[dateFormatter setDateFormat:@"yyyy-MM-dd"];

NSDate *dateFromString=[[NSDate alloc]init];

dateFromString=[dateFormatter dateFromString:dateStr];

[dateFormatter release];

 NSDate *date=[dateFromString dateByAddingTimeInterval:secondsForFollowOn];
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T23:12:48+00:00Added an answer on May 26, 2026 at 11:12 pm
    // Initialize stringified date presentation
    NSString *myStringDate = @"2011-11-17";
    
    // How much day to add
    int addDaysCount = 30;
    
    // Creating and configuring date formatter instance
    NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
    [dateFormatter setDateFormat:@"yyyy-MM-dd"];
    
    // Retrieve NSDate instance from stringified date presentation
    NSDate *dateFromString = [dateFormatter dateFromString:myStringDate];
    
    // Create and initialize date component instance
    NSDateComponents *dateComponents = [[NSDateComponents alloc] init];
    [dateComponents setDay:addDaysCount];
    
    // Retrieve date with increased days count
    NSDate *newDate = [[NSCalendar currentCalendar] 
                                  dateByAddingComponents:dateComponents 
                                                  toDate:dateFromString options:0];
    
    NSLog(@"Original date: %@", [dateFormatter stringFromDate:dateFromString]);
    NSLog(@"New date: %@", [dateFormatter stringFromDate:newDate]);
    
    // Clean up
    [dateComponents release], dateComponents = nil;
    [dateFormatter release], dateFormatter = nil;
    

    Output:

    Original date: 2011-11-17
    New date: 2011-12-17
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I hope someone could help me on this. I want to add a month
I have trouble doing this. I'm creating a method that add working days on
I want to add days to a date to get a new date in
I want to add a variable number of records in a table (days) And
I want to add some no. of days to get the future date. And
I want add new Feed item on entity persist and update. I write this
I want add my custom sidebar next right column all page. Please check this
I have date in this format 1999-05-31T13:20:00.000-05:00 I want to add some hours or
I have date in this format 1999-05-31T13:20:00.000-05:00 I want to add some hours or
I create a form like this with Symfony2: $builder ->add('days', 'date', array( 'widget' =>

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.