sec2dhms.php /** * PHP 格式化秒 */ function vtime($time) { $output = ''; foreach (array(86400 = '天', 3600 = '小时', 60 = '分', 1 = '秒') as $key = $value) { if ($time = $key) $output .= floor($time/$key) . $value; $time %= $key; }
/** * PHP 格式化秒 */ function vtime($time) { $output = ''; foreach (array(86400 => '天', 3600 => '小时', 60 => '分', 1 => '秒') as $key => $value) { if ($time >= $key) $output .= floor($time/$key) . $value; $time %= $key; } return $output; }