You are here

function _video_sec2hms in Video 6

Same name and namespace in other branches
  1. 5 video.module \_video_sec2hms()
  2. 6.2 video.module \_video_sec2hms()

Convert seconds to hours, minutes, and seconds. Derived from h:m:s example by Jon Haworth

@link http://www.laughing-buddha.net/jon/php/sec2hms/

Parameters

$sec: integer value of seconds.

Return value

array associative with key values of hours, minutes, and seconds.

2 calls to _video_sec2hms()
video_form in ./video.module
Hook, displays the contents of the node form page for creating and editing nodes.
video_views_handler_field_playtime_seconds in ./views_video.inc
Handler to to render the correct playtime for the video in a field

File

./video.module, line 1237
video.module

Code

function _video_sec2hms($sec = 0) {
  $hms = array();

  // 3600 seconds in an hour and trash remainder
  $hms['hours'] = intval(intval($sec) / 3600);

  // dividing the total seconds by 60 will give us
  // the number of minutes, but we're interested in
  // minutes past the hour: to get that, we need to
  // divide by 60 again and keep the remainder
  $hms['minutes'] = intval($sec / 60 % 60);
  $hms['seconds'] = intval($sec % 60);

  //keep the remainder.
  return $hms;
}