Convert seconds to H:m:i
Hours could be more than 24

@param mixed $seconds

@return string
422642
protected function secondsToString($seconds)
    {
        $seconds = (int) $seconds;

        $time = array();

        // get hours
        $hours = floor($seconds / 3600);
        $time[] = str_pad($hours, 2, '0', STR_PAD_LEFT);

        // get minutes
        $seconds = $seconds % 3600;
        $time[] = str_pad(floor($seconds / 60), 2, '0', STR_PAD_LEFT);

        // get seconds
        $time[] = str_pad($seconds % 60, 2, '0', STR_PAD_LEFT);

        return implode(':', $time);
    }
1072953
public function format_time( $seconds ) {
		$times = $this->friendly_times( $seconds );

		return sprintf( "%d:%02d:%02d", $times['hours'], $times['minutes'], $times['seconds'] );
	}
241889
function formatTime($seconds) {
		switch (true) {
			case $seconds == 0:
				return 0;
			
			case $seconds < 0.01:
				$time = round($seconds * 1000, 2) . 'ms';
				break;
			
			case $seconds < 0.1:
				$time = round($seconds * 1000, 1) . 'ms';
				break;
			
			case $seconds < 1:
				$time = round($seconds * 1000) . 'ms';
				break;
			
			case $seconds < 10:
				$time = round($seconds, 2) . 's';
				break;
			
			default:
				$time = round($seconds, 1) . 's';
		}
		
		return $time;
	}
95508
public function seconds($seconds) {

		if(false === ('-' . intval($seconds) == '-' . $seconds)) {
   			return trigger_error(sprintf('Argument 1 passed to %s() must be of the type integer, "%s" given', __METHOD__, gettype($seconds)), E_USER_ERROR);
   		}

		$this -> seconds = $seconds;

		return $this;
	}
957114
def seconds_to_text(secs):
    
    hours = (secs)//3600
    minutes = (secs - hours*3600)//60
    seconds = secs - hours*3600 - minutes*60
    return "%02d:%02d:%02d" % (hours, minutes, seconds)
800069
public static function secondsTo($unit, $seconds)
    {
        $method = $unit.'ToSeconds';

        return  (float) $seconds / (float) self::$method();
    }
873346
public function getSecondsAsText($seconds, $decimals = 2, $decPoint = ',', $thousandsSep = '.')
    {
        $seconds = floatval($seconds);

        if (60 > $seconds) {
            return sprintf('%ss', number_format($seconds, $decimals, $decPoint, $thousandsSep));
        }

        $minutes = floor($seconds / 60);

        if (3600 > $seconds) {
            return sprintf('%sm %ss', $minutes, number_format($seconds - ($minutes * 60), 0, $decPoint, $thousandsSep));
        }

        $hours = floor($minutes / 60);
        $minutes = $minutes - ($hours * 60);

        return sprintf('%sh %sm %ss', $hours, $minutes, number_format($seconds - ($minutes * 60) - ($hours * 3600), 0, $decPoint, $thousandsSep));
    }
831109
public static function humanize(
        $seconds,
        array $format = [
            ['microsecond', 'microseconds'],
            ['millisecond', 'milliseconds'],
            ['second', 'seconds'],
            ['minute', 'minutes'],
            ['hour', 'hours'],
            ['day', 'days'],
            ['month', 'months'],
            ['year', 'years'],
        ]
    ): string
    {
        $seconds = $seconds * 1000000;

        $periods = [
            365 * 24 * 60 * 60 * 1000000 => 7,
            30 * 24 * 60 * 60 * 1000000  => 6,
            24 * 60 * 60 * 1000000       => 5,
            60 * 60 * 1000000            => 4,
            60 * 1000000                 => 3,
            1000000                      => 2,
            1000                         => 1,
            1                            => 0,
        ];

        $humanized = '';
        foreach ($periods as $secs => $index) {
            $count = $seconds / $secs;
            if ($count >= 1) {
                $count = (integer)round($count);
                $seconds -= $count * $secs;
                $humanized .= $count . ' ' . ($count > 1 ? $format[$index][1] : $format[$index][0]) . ' ';
            }
        }

        return rtrim($humanized);
    }
1060785
public static function shortDuration($seconds)
    {
        if ($seconds > (60*60)) { // hours
            return round($seconds/(60*60)) . 'h';
        } elseif ($seconds > 60) { // minutes
            return round($seconds/(60)) . 'm';
        } elseif ($seconds >= 1) { // seconds
            return round($seconds) . 's';
        } else {
            return round($seconds*100, 1) . 'ms';
        }
    }
811002
public static function formatSeconds($seconds)
    {
        $format = '';
        $rest = $seconds;
        if ($seconds >= 86400) {
            $format .= floor($seconds/86400).'d ';
            $rest = $seconds%86400;
        }

        if ($rest >= 3600) {
            $format .= floor($rest/3600).'h ';
            $rest = $rest%3600;
        }

        if ($rest >= 60) {
            $format .= floor($rest/60) . 'min ';
            $rest = $rest%60;
        }

        if ($rest > 0) {
            $format .= $rest . 'sec ';
        }

        return trim($format);
    }
833579
public function getSecondsAsTextExtended($seconds)
    {
        $seconds = floatval($seconds);
        $result = [];

        $steps = [
            'days'    => 86400,
            'hours'   => 3600,
            'minutes' => 60,
            'seconds' => 1,
        ];

        foreach ($steps as $stepName => $stepDivider) {
            $stepCount = floor($seconds / $stepDivider);
            if (0 < $stepCount) {
                $result[] = sprintf('%d %s', $stepCount, $this->getTranslator()->transChoice($stepName, $stepCount));
                $seconds = $seconds - ($stepCount * $stepDivider);
            }
        }

        return implode(' ', $result);
    }
708994
def _format_time(seconds):
    

    # Always do minutes and seconds in mm:ss format
    minutes = seconds // 60
    hours = minutes // 60
    rtn = u'{0:02.0f}:{1:02.0f}'.format(minutes % 60, seconds % 60)

    #  Add hours if there are any
    if hours:

        rtn = u'{0:d}h {1}'.format(int(hours % 24), rtn)

        #  Add days if there are any
        days = int(hours // 24)
        if days:
            rtn = u'{0:d}d {1}'.format(days, rtn)

    return rtn
1068298
protected function timeToIso8601Duration($time)
    {
        $units = array(
            "Y" => 365*24*3600,
            "D" =>     24*3600,
            "H" =>        3600,
            "M" =>          60,
            "S" =>           1,
        );
        
        $str = "P";
        $istime = false;
        
        foreach ($units as $unitName => &$unit) {
            $quot  = intval($time / $unit);
            $time -= $quot * $unit;
            $unit  = $quot;
            if ($unit > 0) {
                if (!$istime && in_array($unitName, array("H", "M", "S"))) { // There may be a better way to do this
                    $str .= "T";
                    $istime = true;
                }
                $str .= strval($unit) . $unitName;
            }
        }
        
        return $str;
    }
618283
public function bySeconds(int $seconds): Date
    {
        return $this->secondTo($this->originalDate->seconds() + $seconds);
    }
363466
def to_s
      return "" if @seconds.nil?

      hours, seconds = @seconds.divmod(Hour.to_seconds(1))
      minutes = seconds / Minute.to_seconds(1)
      sprintf("%d:%02d", hours, minutes)
    end
190220
public function timeToText($time, $milliseconds = false)
    {
        $sign = "";
        if ($time < 0) {
            $sign = "-";
        }
        $time = abs($time);
        $cent = str_pad(($time % 1000), 3, '0', STR_PAD_LEFT);
        $time = floor($time / 1000);
        $sec = str_pad($time % 60, 2, '0', STR_PAD_LEFT);
        $min = str_pad(floor($time / 60), 2, '0', STR_PAD_LEFT);
        $hour = str_pad(floor($time / 60 / 60), 1, '0');

        $textTime = $min.':'.$sec;
        if (floor($time / 60 / 60) > 0) {
            $textTime = $hour."'".$textTime;
        }

        if ($milliseconds) {
            $textTime = $textTime.'.'.$cent;
        }

        return $sign.$textTime;
    }
774216
final public static function secondsToSpec($secs)
    {
        if (!empty($secs)) {
            try {
                $interval = self::secondsToInterval($secs);
                return self::intervalToSpec($interval);
            } catch (\Exception $e) {
            }
        }

        return "";
    }