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

  • SEARCH
  • Home
  • 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 4584904
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T21:25:11+00:00 2026-05-21T21:25:11+00:00

thanks to you guys I have successfully converted my array of strings to NSDates.

  • 0

thanks to you guys I have successfully converted my array of strings to NSDates. Now I’m trying to check if today’s date falls in between my 2 dates (namely fromDate and toDate). I’ve seen the following questions but failed to implement them in my code. Be great I can have any other method or help on using the solutions given by the users.

NSDate between two given NSDates

How to Check if an NSDate occurs between two other NSDates

How can I check if an NSDate falls in between two other NSDates in an NSMutableArray

This is what I currently have:

NSDateFormatter *format = [[NSDateFormatter alloc] init];
[format setDateFormat:@"yyyy-MM-dd"];
NSTimeZone *tz = [NSTimeZone localTimeZone];
[format setTimeZone:tz];
NSDate *now = [[NSDate alloc] init];
NSString *todaysDate = [format stringFromDate:now];
NSLog(@"todaysDate: %@", todaysDate);

//converting string - date
int size = [appDelegate.ALLevents count];
for (NSUInteger i = 0; i < size; i++) {
    Event *aEvent = [appDelegate.ALLevents objectAtIndex:i];

    //Convert fromDate
    NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
    [dateFormatter setDateFormat:@"dd-MM-yyyy"];
    NSDate *fromDate = [dateFormatter dateFromString:aEvent.fromDate];
    [dateFormatter setTimeZone:tz];
    NSLog(@"fromDate: %@", fromDate);

    //Convert toDate
    NSDate *toDate = [dateFormatter dateFromString:aEvent.toDate];
    NSLog(@"toDate: %@", toDate);
    [dateFormatter release];
    //Compare if today falls in between
            //codes here
    }
  • 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-21T21:25:12+00:00Added an answer on May 21, 2026 at 9:25 pm

    Do the following,

    NSTimeInterval fromTime = [fromDate timeIntervalSinceReferenceDate];
    NSTimeInterval toTime = [toDate timeIntervalSinceReferenceDate];
    NSTimeInterval currTime = [[NSDate date] timeIntervalSinceReferenceDate];
    

    NSTimeInterval is basically a double type so you can compare that if currTime is greater than one and less than the other than the date falls between those two NSDates.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hi guys thanks for pay attention to this. Well im trying to replace every
Thanks to Stack Overflow and you guys i successfully completed my first project (viz.
hey guys what I am trying to do is have two edit boxes for
Problem solved: Thanks guys, see my answer below. I have a website running in
thanks guys.i managed to complete it.million thanks again specially for DAVID,WM-EDDIE and S.LOTT.also STACKOVERFLOW
Update: Thanks guys, I didn't realize it was very close to zero but not
Thanks to the epic work of Dennis Williamson, I am now able to calculate
Thanks for reading this. I have no idea why this is throwing a NullReferenceException
thanks for your reading. I am trying to modify Jquery Nivo Zoom plugin to
I have the Jquery Cycle Plugin ... http://jquery.malsup.com/cycle/ ... and I'm trying to figure

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.