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

The Archive Base Latest Questions

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

Im trying to know if a date is in between other 2. The tricky

  • 0

Im trying to know if a date is in between other 2. The tricky thing is that these dates are just formed by a weekday and time. To do so, and skip previous problems, I took the very first weekdays, those are January 1970. So I take the current weekday and make it from 1970, like this:
NSDate *dateNow = [NSDate date];

    NSDateFormatter* dateFormatter = [[NSDateFormatter alloc] init];
    [dateFormatter setLocale:[[[NSLocale alloc] initWithLocaleIdentifier:@"en"] autorelease]];
    [dateFormatter setDateFormat:@"EEEE HH:mm"];    

    NSString *dateString = [dateFormatter stringFromDate:dateNow];

    NSLog(@"La fecha es: %@", dateString);

    NSDate *dateComp =  [dateFormatter dateFromString:dateString];//Date and time in 1970

I compare this date with fix dates (weekday and time) and look it it’s in any interval, like this:

NSDateFormatter* dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setLocale:[[[NSLocale alloc] initWithLocaleIdentifier:@"en"] autorelease]];
[dateFormatter setDateFormat:@"EEEE HH:mm dd-MM-y"];    
NSString *dateString = [dateFormatter stringFromDate:self.fechaInicio];

NSLog(@"La date start es: %@", dateString);

dateString = [dateFormatter stringFromDate:self.fechaFin];

NSLog(@"La Date end es: %@", dateString);
dateString = [dateFormatter stringFromDate:testDate];

NSLog(@"DAte inside es: %@", dateString);

NSLog(@"time interval nicio: %d", [testDate timeIntervalSinceDate:self.fechaInicio]);
NSLog(@"time interval fin: %d", [testDate timeIntervalSinceDate:self.fechaFin]);

but this is the output

Palyque[746:307] La date start es: Monday 09:00 05-01-1970
2011-11-23 11:34:47.857 Palyque[746:307] La Date end es: Monday 16:00 05-01-1970
2011-11-23 11:34:47.861 Palyque[746:307] DAte inside es: Wednesday 11:34 07-01-1970
2011-11-23 11:34:47.864 Palyque[746:307] time interval nicio: 0 
2011-11-23 11:34:47.867 Palyque[746:307] time interval fin: 0

Any ideas? Why is 0, always? I print the dates before calculting the timeIntervalSinceDate and it looks fine…

  • 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:45:59+00:00Added an answer on May 26, 2026 at 11:45 pm

    NSTimeInterval is a floating point number. You have to use the %f format specifier to log these values.

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

Sidebar

Related Questions

I'm trying to select a specific date between two dates. The forma its stored
I am trying to create a function that can subtract between 2 dates but
Does anybody know which date format is to be used, trying to create a
I'm trying get only the Saturdays and Sundays between two dates, but I don't
I know how that question looks, but I'm quite serious. I am trying to
I'm trying to select all dates between 2 dates. In the database I have
Anyone know of a (reliable) date recurrence calculator, we're trying to implement something in
I am trying to do a query between 2 dates. I would like to
I need to get the number of minutes between two dates. I know Joda
I know very little about JavaScript but despite this I'm trying to cobble something

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.