How to covert seconds into SMPTE time code

Example:

I have a value of 10.331667

How do I convert that to 00:00:10.33
MarkProgrammerAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Dave BaldwinFixer of ProblemsCommented:
MarkProgrammerAuthor Commented:
Unfortunately not. In the interim I am using ffprobe's output.
Ray PaseurCommented:
PHP has no direct way to convert the SMPTE value into HH:MM:SS.TH fractions, so there will be some amount of programming involved.  This might give you a starting point.  It rounds the fractional seconds to a two-digit decimal value.
http://iconoun.com/demo/temp_mark.php

<?php // demo/temp_mark.php
/**
 * http://www.experts-exchange.com/questions/28899303/How-to-covert-seconds-into-SMPTE-time-code.html
 *
 * https://en.wikipedia.org/wiki/SMPTE_timecode
 * http://php.net/results.php?q=smpte&l=en&p=all
 *
 * http://www.experts-exchange.com/articles/201/Handling-Date-and-Time-in-PHP-and-MySQL-Procedural-Version.html
 * http://www.experts-exchange.com/articles/20920/Handling-Time-and-Date-in-PHP-and-MySQL-OOP-Version.html
 *
 * http://php.net/manual/en/datetime.formats.php
 * http://php.net/manual/en/datetime.formats.date.php
 *
 * http://php.net/manual/en/function.explode.php
 * http://php.net/manual/en/function.strtotime.php
 * http://php.net/manual/en/function.date.php
 */
error_reporting(E_ALL);
echo '<pre>';


// A FUNCTION TO CONVERT THE DATA
function smpte_timecode($dat)
{
    // ROUND THE TIME AND BREAK APART ON THE DECIMAL, GIVING SECONDS, FRACTIONS
    $dat = number_format($dat,2);
    $arr = explode('.', $dat);
    return date('H:i:s', strtotime('Today ' . $arr[0] . ' seconds'))
    . '.'
    . substr($arr[1], 0, 2)
    ;
}


// A SAMPLE CONVERSION
$dat = 10.331667;
echo PHP_EOL . $dat;
echo PHP_EOL . smpte_timecode($dat);

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
MarkProgrammerAuthor Commented:
Thanks
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.