将秒数转换成时分秒
function changeTimeType($seconds)
{
if ($seconds > 3600) {
$hours = intval($seconds / 3600);
$time = $hours . ":" . gmstrftime('%M:%S', $seconds);
} else {
$time = gmstrftime('%H:%M:%S', $seconds);
}
return $time;
}

将秒数转换成年月日时分秒
function Sec2Time($time)
{
if (is_numeric($time)) {
$value = array(
"years" => 0, "days" => 0, "hours" => 0,
"minutes" => 0, "seconds" => 0,
);
$t = '';
if ($time >= 31556926) {
$value["years"] = floor($time / 31556926);
$time = ($time % 31556926);
$t .= $value["years"] . "年";
}
if ($time >= 86400) {
$value["days"] = floor($time / 86400);
$time = ($time % 86400);
$t .= $value["days"] . "天";
}
if ($time >= 3600) {
$value["hours"] = floor($time / 3600);
$time = ($time % 3600);
$t .= $value["hours"] . "小时";
}
if ($time >= 60) {
$value["minutes"] = floor($time / 60);
$time = ($time % 60);
$t .= $value["minutes"] . "分";
}
$value["seconds"] = floor($time);
$t .= $value["seconds"] . "秒";
return $t;
} else {
return (bool)false;
}
}
$a = 50;
echo Sec2Time($a);
echo "<hr><br>";
$b = 89;
echo Sec2Time($b);
echo "<hr><br>";
$c = 120;
echo Sec2Time($c);
echo "<hr><br>";
$c = 4567;
echo Sec2Time($c);
echo "<hr><br>";
$c = 8522;
echo Sec2Time($c);
echo "<hr><br>";
$c = 18522;
echo Sec2Time($c);
echo "<hr><br>";
$c = 138522;
echo Sec2Time($c);
echo "<hr><br>";
$c = 1385322;
echo Sec2Time($c);
echo "<hr><br>";
