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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T17:16:15+00:00 2026-06-17T17:16:15+00:00

Possible Duplicate: hours minutes seconds to seconds ios I have a time formatted as

  • 0

Possible Duplicate:
hours minutes seconds to seconds ios

I have a time formatted as such

// format: HH:mm:ss,AAA
// example for 2 hours, 35 minutes, 15 seconds, and 207 milliseconds
02:35:15,207

I’m trying to convert that into seconds as a double. The above example would turn into:

// 2 hrs * 3600 + 25 min * 60 + 15.207
9315.207

I figure I can pick apart each element with a scanner, but I’m thinking there’s probably an easier way. I tried using NSDateFormatter but I need this as a double, not as an NSDate. Any suggestions? Thanks.

Further FYI

This is for use with the MPMoviePlayer and the currentTime property is a double. For any given section where I have data to show, I am checking if dataStartTime <= playerTime < dataEndTime. So I’m using double because that’s the type for currentTime already.

  • 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-06-17T17:16:16+00:00Added an answer on June 17, 2026 at 5:16 pm

    Here is the solution, the idea is simple get two date one with your time and one with 00:00:00,000 time then take difference of their time.

    - (double)secondsFromString:(NSString*)str {
        NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
        [formatter setDateFormat:@"yyyy-MM-dd HH:mm:ss,SSS"];
        NSString *dateString = @"1970-01-01";
        NSDate *date = [formatter dateFromString:[NSString stringWithFormat:@"%@ %@",dateString,str]];
        NSDate *refDate = [formatter dateFromString:[NSString stringWithFormat:@"%@ 00:00:00,000",dateString]];
        double time = [date timeIntervalSince1970] - [refDate timeIntervalSince1970];
        return time;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: NSNumber of seconds to Hours, minutes, seconds I have a large number
Possible Duplicate: Calculate DateDiff in SQL in Days:Hours:Mins:Seconds format I have this MySql query:
Possible Duplicate: Convert seconds to days, minutes, and hours in Obj-c How to do
Possible Duplicate: Time diff in minutes between 2 dates php date_diff in hours i
Possible Duplicate: Convert seconds into days, hours, minutes, seconds in PHP How to convert
Possible Duplicate: How to convert Milliseconds to X mins, x seconds in Java? Calculating
Possible Duplicate: PHP: producing relative date/time from timestamps please see the example of PHP
Possible Duplicate: How do I calculate relative time? I want to format dates on
Possible Duplicate: Wrong time from NSDateFormatter NSDate is 5 hours off I am trying
Possible Duplicate: MySQL convert timediff output to day, hour, minute, second format I have

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.