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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T21:26:33+00:00 2026-06-13T21:26:33+00:00

I hope you can help me with this: I´m writing a App that should

  • 0

I hope you can help me with this:

I´m writing a App that should show if a shop has actually open.
For this i declared for each day and each opening times different variables / NSDate-Objects like (setting the dateformatter I´ve done before):

    NSDate *mondayMorningOpening = [dateFormatter dateFromString:@"08:00"];
    NSDate *montagMorningClosing = [dateFormatter dateFromString:@"12:30"];
    NSDate *mondayNoonOpening = [dateFormatter dateFromString:@"15:00"];
    NSDate *montagNoonClosing = [dateFormatter dateFromString:@"21:30"];

I´ve also set a NSDate for the actual time:

    NSString *tempDate1 = [dateFormatter stringFromDate:date];
    NSDate *actualTime = [dateFormatter dateFromString:tempDate1];

Now I want to calculate if the actual time is before or after the time range for the opening times of the shop. I´ve done this:

    if ([actualTime earlierDate: mondayMorningClosing && [aktuelleZeit laterDate: mondayMorningOpening])
        {
         NSLog (@"The shop is open!");
        }
    else if ([actualTime earlierDate: mondayNoonClosing]&& [actualTime laterDate: mondayNoonOpening])
        {
         NSLog (@"The shop is open!");
        }
    else
        {
         NSLog (@"The shop is closed!");
        }

But no matter what time it is, it´s always shown “The shop is open!”.

Maybe you have an idea what to do that i can show the opening status right…

  • 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-13T21:26:35+00:00Added an answer on June 13, 2026 at 9:26 pm

    You misunderstood the meaning of earlierDate and laterDate.The methods are not “isEarlierDate” and “isLaterDate”, they do not return a BOOL.These methods return a NSDate object, the earlier (or later) of the two dates.They’re not nil objects, so they’re always evaluated to true.

    Compare the two dates taking it’s time interval:

    if ([actualTime timeIntervalSinceDate: mondayMorningClosing]<0 && [aktuelleZeit timeIntervalSinceDate: mondayMorningOpening]>0)
    {
        NSLog (@"The shop is open!");
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I hope you can help. This has been confounding me for hours. I have
I hope that there is someone that can help with this problem since I
I hope someone can help me with this, as I'm unable to find the
Hope someone can help me out with this problem I am having. I just
Hope someone can help i cant seem to get my head around this, i
I hope someone can help me here. I'm having trouble loading this variable. Right
I hope some of you guys can help me with this problem.... I have
I hope you can help me. I have a web service that needs to
this my first question on here. I hope someone can help. It is to
Hope you can help me with this one. I need to make a program

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.