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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T13:35:55+00:00 2026-05-31T13:35:55+00:00

I have a strings – time, start, end: format hh:mm for example, 21:00. I

  • 0

I have a strings – time, start, end: format “hh:mm”

for example, “21:00”.
I need compare – “time” falls between the Start and End
if End < Start, for example (“21:10” “10:00”) should be considered as: from ‘Start’ to ‘End’ the next day.

I can’t convert NSSTring like @”23:00″ to NSDate, and then I need to compare… 🙁

Thanks for advice 😉

  • 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-31T13:35:56+00:00Added an answer on May 31, 2026 at 1:35 pm

    You can convert a string of type HH:mm into an NSDate. If endDate is smaller than startDate, then add a day to it.

    NSString *dateString = @"23:00";
    NSString *startString = @"21:00";
    NSString *endString = @"10:00";
    
    NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
    formatter.dateFormat = @"HH:mm";
    
    NSDate *date = [formatter dateFromString:dateString];
    NSDate *startDate = [formatter dateFromString:startString];
    NSDate *endDate = [formatter dateFromString:endString];
    if ([endDate compare:startDate] == NSOrderedAscending) {
        endDate = [endDate dateByAddingTimeInterval:24*3600];
    }
    
    if ([startDate compare:date] == NSOrderedAscending && [date compare:endDate] == NSOrderedAscending) {
        NSLog(@"Date %@ is in the interval [%@, %@]", dateString, startString, endString);
    } else {
        NSLog(@"Date %@ is not in the interval [%@, %@]", dateString, startString, endString);
    }
    

    PS. I am assuming ARC is used here.

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

Sidebar

Related Questions

I have strings of the format '15:10:21' for time, and I also know the
I have strings like: -4:00 3:15 +8:30 I need to format them as UTC
I have strings like follow field_zip_code:48103 taxonomy:88 field_zip_code:48103 taxonomy:88 field_state:MI field_zip_code:48103 From here i
I have strings like: Avery® Laser &amp; Inkjet Self-Adhesive I need to convert them
I have strings formatted using the code below String.Format({0,-10} {1,10}, Kills:, kills); String.Format({0,-10} {1,10},
I have strings that need converting like so, 'hello world' = 'helloWorld' And also
For example I have code below string txt=I have strings like West, and West;
I have strings with this format: a,b, c,d and this format: a(b,c,d) I want
I have strings like this ' some-dasd\dasd-dasdas\dasdas-dasd-das\dsad '. I need to split the string
I have strings like these: text-23 the-text-9 2011-is-going-to-be-cool-455 I need to remove the final

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.