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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T23:34:11+00:00 2026-06-02T23:34:11+00:00

I need to check an event date, which should be between Current date and

  • 0

I need to check an event date, which should be between Current date and 60 days from now. The below code is used, but it is NOT working correctly. Please note, i’m getting event string like this – “2012-04-14T16:50:02Z” from my server.

    // current date
double currDateInMilliSecs = [NSDate timeIntervalSinceReferenceDate] * 1000;    
NSLog(@"currDateInMilliSecs: %f", currDateInMilliSecs);

// sixty days
double sixtydaysvalue = 60.0 * 24.0 * 3600.0 * 1000.0;
NSLog(@"sixtydaysvalue: %f", sixtydaysvalue);
// add current date + sixt days
double sixtyDaysMilliSecsFromCurrDate = currDateInMilliSecs + sixtydaysvalue;
NSLog(@"sixtyDaysMilliSecsFromCurrDate: %f", sixtyDaysMilliSecsFromCurrDate);

// check does the event date between current date + 60 days
NSDateFormatter *df = [[NSDateFormatter alloc] init];
//[df setTimeZone:[NSTimeZone timeZoneWithName:@"UTC"]];
[df setDateFormat:@"yyyy-MM-dd'T'HH:mm:ss'Z'"];
//[df setDateFormat:@"yyyy-MM-dd HH:mm:ss"];

// [eventDict objectForKey:@"begin_at"] gives date string like this "2012-04-14T16:50:02Z"  for ex.
NSDate *eventdate = [df dateFromString:[eventDict objectForKey:@"begin_at"]];

NSTimeInterval nowSinceEventDate = [eventdate timeIntervalSince1970];
NSLog(@"nowSinceEventDate: %f", nowSinceEventDate);
double eventDateInMilliSecs = nowSinceEventDate * 1000;
NSLog(@"eventDateInMilliSecs: %f", eventDateInMilliSecs);

// this is not working as expected    
if ( eventDateInMilliSecs<sixtyDaysMilliSecsFromCurrDate && eventDateInMilliSecs>currDateInMilliSecs )
{


}
else
{
}
  • 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-02T23:34:13+00:00Added an answer on June 2, 2026 at 11:34 pm

    You’re trying to solve this as if it were Java, which it’s not. Instead, try using things from the Cocoa Touch frameworks. Since your calculations are rather simple, you can do them with dates, but more complex things can pretty easily be done using NSCalendar and NSDateComponents.

    A simple solution to your problem (here we assume eventdate is the date you created using your formatter):

    NSDate* now = [NSDate date];
    NSDate* sixtyDaysFromNow = [now dateByAddingTimeInterval:(60 * 60 * 24 * 60)];
    if( [eventDate earlierDate:now] == now && [eventDate laterDate:sixtyDaysFromNow] == sixtyDaysFromNow ) {
      // the event date is within scope
    } else {
      // the event date is outside stop
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to check (from the same table) if there is an association between
I need to check whether a given date is in the preceding month for
I need to check if a TCP/IP route already exists from my application and
On postback, how can I check which control cause postback in Page_Init event. protected
I need to check that a UK date, stored as string in the format
I need to check in some fast way if there is any text nodes
I need to check if a database is totally empty (no tables) using an
I need to check specific positions in an NSArray to see if they have
I need to check the size of the uploaded primary file in Oracle UCM
I need to check the type of each element in an array... for(id obj

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.