function secsToStr($secs) { if($secs>=86400){$days=floor($secs/86400); $secs=$secs%86400; $r=$days.' day'; if($days<>1){$r.='s';} if($secs>0){$r.=', ';}} if($secs>=3600){$hours=floor($secs/3600); $secs=$secs%3600; $r.=$hours.' hour'; if($hours<>1){$r.='s';} if($secs>0){$r.=', ';}} if($secs>=60){$minutes=floor($secs/60); $secs=$secs%60; $r.=$minutes.' minute'; if($minutes<>1){$r.='s';} if($secs>0){$r.=', ';}} $r.=$secs.' second'; if($secs<>1){$r.='s'; } return $r; }
<?php $seconds = "56789"; $output = secsToStr($seconds); echo $output; ?>
以上就是PHP把秒轉換成天數,小時數和分鐘 的內容,更多相關內容請關注php中文網
相關工具:Unix時間戳轉換工具 http://www.php.cn/xiazai/tool/5
相關文章: