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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T00:29:38+00:00 2026-05-25T00:29:38+00:00

Currently I’m recording the time between two events in decimal minutes using : NSCalendar

  • 0

Currently I’m recording the time between two events in decimal minutes using :

NSCalendar *calendar = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];
NSCalendarUnit unitFlags = NSYearCalendarUnit | NSMonthCalendarUnit | NSWeekCalendarUnit | NSDayCalendarUnit | NSHourCalendarUnit | NSMinuteCalendarUnit | NSSecondCalendarUnit;
NSDate *date = [NSDate date];
NSDateComponents *dateComponents =  [calendar components:unitFlags fromDate:date];

CGFloat hour = [dateComponents hour];
CGFloat minute = [dateComponents minute];
CGFloat second = [dateComponents second];

//set start time in decimal minutes
CGFloat startTime = ((hour*3600.0)+(minute*60.0)+(second))*.016666;

//do work...

//set end time in decimal minutes
CGFloat endTime = ((hour*3600.0)+(minute*60.0)+(second))*.016666;

//calculate time elapsed in decimal minutes
CGFloat totalTime = endTime-startTime;

The issue that I’m having is that I am really only getting the time in seconds and then converting to decimal minutes. So, the only values that I’m getting are 0.016663 (one second in decimal minutes), 0.033325 (two seconds in decimal minutes), 0.049988 (three seconds in decimal minutes), etc. I’m not getting any values in between. Is there any way I can get a more accurate time? I checked to see if NSDateComponents has a millisecond property or whatnot, but I couldnt find any.

Thanks!

  • 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-25T00:29:38+00:00Added an answer on May 25, 2026 at 12:29 am

    You can also use CFAbsoluteTimeGetCurrent() which returns a double containing time in seconds and fractions of a second:

    CFAbsoluteTime startTime = CFAbsoluteTimeGetCurrent();
    

    Then later you can compute an elapsed time in seconds and fractions of a second:

    elapsed = CFAbsoluteTimeGetCurrent() - startTime;
    
    NSLog(@"Elapsed Time: %0.3f seconds", elapsed);
    

    I like to have debug code (#ifdef DEBUG) in my app delegate and in viewDidAppear in my first view controller to report the elapsed startup time so I can keep an eye on that while developing.

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

Sidebar

Related Questions

Currently i'm having trouble using two functions in my -(void)viewDidLoad , both of these
Currently, working with Denali RC0 and unable to add BI Time Intelligence to the
Currently I'm transferring a String across the network, using DataInput/OutputStream's. The String I am
Currently I am using Amazon Cloudfront to service static objects on my ASP.Net MVC3
Currently I have in my code tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(addCompoundToLabel:)]; My code
Currently I am using a pretty basic function to pre-load images: function preload(arrayOfImages) {
Currently I know of only two ways to cache data (I use PHP but
Currently I am doing mass deletes using variations of the following query: DELETE FROM
Currently I am using the command line compilation for my project and i used
Currently I have a simple setup where I maintain a list of bools corresponding

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.