function _emvideo_seconds_to_time in Embedded Media Field 6
Same name and namespace in other branches
- 6.3 contrib/emvideo/emvideo.theme.inc \_emvideo_seconds_to_time()
- 6.2 contrib/emvideo/emvideo.theme.inc \_emvideo_seconds_to_time()
Display seconds as HH:MM:SS, with leading 0's.
Parameters
$seconds: The number of seconds to display.
2 calls to _emvideo_seconds_to_time()
- emvideo_seconds_to_time in contrib/
emvideo/ emvideo.module - theme_emvideo_video_duration in contrib/
emvideo/ emvideo.theme.inc
File
- contrib/
emvideo/ emvideo.theme.inc, line 378 - This defines the various theme functions for Embedded Video Field (emvideo).
Code
function _emvideo_seconds_to_time($seconds) {
// Number of seconds in an hour.
$unith = 3600;
// Number of seconds in a minute.
$unitm = 60;
// '/' given value by num sec in hour... output = HOURS
$hh = intval($seconds / $unith);
// Multiply number of hours by seconds, then subtract from given value.
// Output = REMAINING seconds.
$ss_remaining = $seconds - $hh * 3600;
// Take remaining seconds and divide by seconds in a min... output = MINS.
$mm = intval($ss_remaining / $unitm);
// Multiply number of mins by seconds, then subtract from remaining seconds.
// Output = REMAINING seconds.
$ss = $ss_remaining - $mm * 60;
$output = '';
// If we have any hours, then prepend that to our output.
if ($hh) {
$output .= "{$hh}:";
}
// Create a safe-for-output MM:SS.
$output .= check_plain(sprintf($hh ? "%02d:%02d" : "%d:%02d", $mm, $ss));
return $output;
}