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 need to calculate Math.exp() from java very frequently, is it possible to get
I need to calculate averages, standard deviations, medians etc for a bunch of numerical
How do I calculate the position of an accelerating body (e.g. a car) after
I want to calculate the time span between 2 times which I saved in
to calculate some longitude and latitude values I need more decimal places like mysql
I need to calculate Crc16 checksums with a $1021 polynom over large files, below
How can I calculate the time differences in 24 hour if the user input
I need to calculate Gps Location on the move and on deviation from certain
I need to calculate the Italian fiscal code (tax code) in C#. I've found
I need to calculate the number of weeks difference between the chosen date and

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.