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 9000593
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T00:19:50+00:00 2026-06-16T00:19:50+00:00

Possible Duplicate: iPhone – get number of days between two dates I am trying

  • 0

Possible Duplicate:
iPhone – get number of days between two dates

I am trying to compare 2 dates and find out the number of day in between them.

something like below:

now = [NSDate date];

// This is i am saving in NSUSerdefault on some condition,like 

if (a == 1) {

    dateFormatter = [[NSDateFormatter alloc] init];
    dateFormatter.dateFormat = @"yyyy-MM-dd HH:MM:SS";
    [dateFormatter setTimeZone:[NSTimeZone systemTimeZone]];
    NSLog(@"The Current Time is %@",[dateFormatter stringFromDate:now]);
    datesaved = [NSString stringWithFormat:@"%@",[dateFormatter stringFromDate:now]];
    NSLog(@"old date saved : %@",datesaved);

    [dateFormatter release];
}

and
find current date .

Now i want to compare current date with the date saved in NSUserDefaults to find number of day in between them.

ex:

The Current Time is 2012-12-16 19:12:74
old date saved : 2012-12-12
19:12:74

Number of days : 4

Thanks

  • 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-06-16T00:19:50+00:00Added an answer on June 16, 2026 at 12:19 am
    NSDate *date1 = [NSDate dateWithString:@"2010-01-01 00:00:00 +0000"];
    NSDate *date2 = [NSDate dateWithString:@"2010-02-03 00:00:00 +0000"];
    
    NSTimeInterval secondsBetween = [date2 timeIntervalSinceDate:date1];
    
    int numberOfDays = secondsBetween / 86400;
    
    NSLog(@"There are %d days in between the two dates.", numberOfDays);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: On iPhone: Find out what song is currently playing? (in the iPod
Possible Duplicate: iPhone CodeSign failed From last two days i am facing following error
Possible Duplicate: Android - iphone style tabhost I am trying to figure out how
Possible Duplicate: Ad Hoc Wifi Connection Between iPhone & Mac - Possible? How can
Possible Duplicate: How to Get time difference in iPhone I´m getting date and time
Possible Duplicate: iphone fading of images How can implement fading out animation in to
Possible Duplicate: iPhone development - what is the difference between a development and distribution
Possible Duplicate: iPhone Interface Builder and Delegates What is the relationship between these three
Possible Duplicate: Determine device (iPhone, iPod Touch) with iOS I have tried to get
Possible Duplicate: merge Audio files on iPhone I'm trying to combine 2 audio files

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.