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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T23:00:32+00:00 2026-05-13T23:00:32+00:00

I got help with correct calculation the other day but I’ve hit a block

  • 0

I got help with correct calculation the other day but I’ve hit a block about how to implement it into code.

-(IBAction)done:(id)sender {
  int result = (([startHours.text intValue] * 60) + [startMinutes.text intValue]) - 
  (([finishHours.text intValue] * 60) + [finishMinutes.text intValue]);
  totalHours.text = [NSString stringWithFormat:@"%i", result / 60];
  if (result < 0) { 
    totalHours.text = [NSString stringWithFormat:@"%d", result * -1];
  }

The above is the code. However, in the text field it comes out as the total number of minutes. I want to covert it so it would show up as total hours and minutes (10.30). How would I do that in code?

  • 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-13T23:00:32+00:00Added an answer on May 13, 2026 at 11:00 pm

    Pheelicks’s answer is OK. Just two small additions: handle sign of interval before calculating parts, and use more common time format:

      int result = (([startHours.text intValue] * 60) + [startMinutes.text intValue]) - 
      (([finishHours.text intValue] * 60) + [finishMinutes.text intValue]);
    
      int minutes = abs(result)%60
      int hours = (abs(result) - minutes)/60
      totalHours.text = [NSString stringWithFormat:@"%02d:%02d", hours, minutes];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So I have a tiny problem. I got help here a while ago about
I got some code off the Internet and now I just need help to
Since I've got more than one correct answer, I'm answering Thanks for your help
Need quick help from win developers. Please correct me where I got it wrong.
this code i got is from Alexander Battisti about how to make a tree
Got some great help yesterday with some php code for a mailer and forgot
Please help me to make a correct request to Facebook api. Now i've got:
I've got a little problem with correct query and hope you can help me.
I worked on this yesterday about 5 hours and got the code to work
I just got help in how to compile this script a few mintues ago

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.