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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T11:37:20+00:00 2026-05-23T11:37:20+00:00

I have 2 text fields where users can insert 2 time (ie. 12.00pm and

  • 0

I have 2 text fields where users can insert 2 time (ie. 12.00pm and 15.00pm) and a label that return the hours (ie 3 hours). I’m using timeIntervalSinceDate but I’m getting it in seconds (10800 sec which is equal to 3 hours). How can I get the value in hours? here the code:

-(IBAction)calcoloBlockTime{
   NSString *blockOff = [NSString stringWithFormat:@"%@", [offBlock text]];
   NSString *blockIn= [NSString stringWithFormat: @"%@", [inBlock text]];
   NSDateFormatter *dateFormatter =[[NSDateFormatter alloc]init];
   [dateFormatter setDateFormat:@"HHmm"];
   NSDate *dateFromString = [dateFormatter dateFromString:blockOff];
   NSDate *dateFromString2 = [dateFormatter dateFromString:blockIn];
   NSLog(@"Time elapsed: %f", [dateFromString2 timeIntervalSinceDate:dateFromString]);
}

thanks in advance.

  • 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-23T11:37:21+00:00Added an answer on May 23, 2026 at 11:37 am

    If you are only interested in hours you can write:

    NSInteger hours = 10800 / 3600; // You know that in an hour there is 3600 seconds

    If you want minutes etc you will continue with the result of 10800 modulus 3600, which will give you the seconds which are left after dividing it by 3600.

    NSInteger temp = 10800 % 3600;
    NSInteger minutes = temp / 60;

    And to get the seconds left after this you write:

    NSInteger seconds = minutes % 60;


    EDIT

    myLabel.text = [NSString stringWithFormat:@"%d hours", hours];
    

    If you want to set the hours on the label.

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

Sidebar

Related Questions

I have a form where users can add input fields with jQuery. <input type="text"
I have two text fields in my view. I did it using IB. My
I have n number of text fields named in the form Question...... How can
I have a text field where the user can insert the date and the
For web sites that have username/password text input fields, the browser usually handily offers
Creating a JApplet I have 2 Text Fields, a button and a Text Area.
I have one form with several text fields and one button. When i enter
I have a simple row that has 4 columns: { [Primary Key Int]RowID, [text]Title,
I have a text field that is disabled based on who the user is.
I have a field where the user can input text and I want them

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.