/************************************************************************ * 函数名称:intervalTime() * 函数说明:根据秒数返回(天,小时,分钟,秒) * 输入参数: $time 要转换的秒数 * 返 回 值:数组 格式:array("days"=>"天","hour"=>"小时","minute"=>"分钟","second"=>"秒") * 编 写 者:李小宇 * 编写时间:2011/7/27 **************************************************************************/ function intervalTime($time) { //计算天 $days = ($time>=86400) ? floor($time/86400) : 0; //计算小时 $temp = $time-86400*$days; $hour = ($temp>=3600 && $temp<86400) ? floor($temp/3600) : 0; //计算分钟 $temp = $time-86400*$days-3600*$hour; $minute = ($temp>=60 && $temp<3600) ? floor($temp/60) : 0; //计算秒 $temp = $time-86400*$days-3600*$hour-60*$minute; $second = ($temp>0 && $temp<60) ? $temp : 0; $result = array( "days"=>$days, "hour"=>$hour, "minute"=>$minute, "second"=>$second ); return $result; }