标签:秒数转换成时分秒
/**
转换时间格式
*/
function changeTimeType($time) {
if (is_numeric($time)) {
$value = array(
"days" => 0, "hours" => 0,
"minutes" => 0, "seconds" => 0,
);
if ($time >= 86400) {
$value["days"] = floor($time / 86400);
$time = ($time % 86400);
}
if ($time >= 3600) {
$value["hours"] = floor($time / 3600);
$time = ($time % 3600);
}
if ($time >= 60) {
$value["minutes"] = floor($time / 60);
$time = ($time % 60);
}
$value["seconds"] = floor($time);
if(strlen($value["hours"])<2 && $value["days"]==0){
$value["hours"]="0".$value["hours"];
}else if(strlen($value["hours"])<2 && $value["days"]!=0){
$value["hours"]=$value["days"] * 24 + $value["hours"];
}else{
$value["hours"]=$value["days"] * 24 + $value["hours"];
}
if(strlen($value["minutes"])<2){
$value["minutes"]="0".$value["minutes"];
}
if(strlen($value["seconds"])<2){
$value["seconds"]="0".$value["seconds"];
}
//return (array) $value;
$t = $value["hours"] . ":" . $value["minutes"] . ":" . $value["seconds"];
Return $t;
} else {
return "00:00:00";
}
}
本文出自 “phpAjax请求” 博客,谢绝转载!
标签:秒数转换成时分秒
原文地址:http://15129824665.blog.51cto.com/10510385/1843050