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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T00:36:31+00:00 2026-05-26T00:36:31+00:00

how to calculate Mid night time intervals in iphone development? i am working on

  • 0

how to calculate Mid night time intervals in iphone development?

i am working on stock market app, and i need to calculate a timeinterval after market closed.

suppose stock market is closed at 6:30 pm after that i need to time interval till 12:00

  • 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-26T00:36:32+00:00Added an answer on May 26, 2026 at 12:36 am

    Yes, You really should provide more info about your input data.
    Because if you have two NSDate values containing full date and time info you need nothing more than timeIntervalSinceDate:

        NSDateFormatter * dateFormatter = [[NSDateFormatter alloc] init];
        [dateFormatter setDateFormat:@"MM.dd.yyyy hh:mm a"];    
        NSDate * date1 = [dateFormatter dateFromString:@"01.11.2011 06:30 PM"];
        NSDate * date2 = [dateFormatter dateFromString:@"01.12.2011 12:00 PM"];
        NSTimeInterval interval = [date2 timeIntervalSinceDate:date1];
    

    You’ll get 63000 s = 17.5 h

    But it looks like you have times without date information. In this case you’ll get wrong negative value:

    [dateFormatter setDateFormat:@"hh:mm a"];
    NSDate * date1 = [dateFormatter dateFromString:@"06:30 PM"];
    NSDate * date2 = [dateFormatter dateFromString:@"12:00 PM"];
    NSTimeInterval interval = [date2 timeIntervalSinceDate:date1];
    

    result is -23400 s = -6.5 h

    So in this case you should correct the result, because you know second date is after midnight:

    NSTimeInterval rightInterval = 24*3600 + [date2 timeIntervalSinceDate:date1];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to calculate the time it takes to receive all data from a
to calculate some longitude and latitude values I need more decimal places like mysql
I calculate a number of sums and I need to find the minimum of
I have some documents and its created time is in milliseconds. I need to
I have a 15 digit customer number that I need to calculate a check
I want to calculate time difference in milliseconds from current time of a day(11
Any idea how to build datediff query that calculate time that possibly crosses midnight?
I need to set a date and time to 12 midnight regardless of the
I know that to calculate measurement error in need to use an ANOVA, but
I have a requirement to calculate summary statistics aggregated by specific custom time periods.

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.