Convert seconds to time format I have 10396080 seconds, and I want it to look like this: xxx hours, xxx minutes.
Is there some function for that?
I have 10396080 seconds, and I want it to look like this: xxx hours, xxx minutes. Is there some function for that?


Not really.  What you want is 10396080 seconds converted to 2887 hours 48 minutes, and I know of now existing function that does that.

There  is format_interval().

 $seconds = 10396080;
 $string = format_interval($seconds, 2);
 echo $string;


But that will output "4 months 7 hours".

However, the following custom function:

 function _hoursminutes($interval, $granularity = 2, $langcode = NULL) {
   $units = array(
    '1 hour|@count hours' =&gt; 3600,
    '1 minute|@count minutes' =&gt; 60,
    '1 seconds|@count seconds' =&gt; 1,
  );  $output = '';
  foreach ($units as $key =&gt; $value) {
    $key = explode('|', $key);
    if ($interval &gt;= $value) {
      $output .= ($output ? ' ' : '') .
        format_plural(floor($interval / $value), $key[0], $key[1], array(),
        array('langcode' =&gt; $langcode));
      $interval %= $value;
      $granularity--;
    }
    if ($granularity == 0) {
      break;
    }
  }
  return $output ? $output : t('0 second', array(), array('langcode' =&gt; $langcode));
}

 $seconds = 10396080;
 $string = _hoursminutes($seconds, 2);
 echo $string;


This will output: "2887 hours 48 minutes", which presumably what you want.