Share methods seconds turn into a time of her own writing.
Those online, are copy to copy, but do not meet business needs.
The method of achieving this is to convert one second string level to "read" time display format.
If the length of time to reach the range, then no display.
Because of the length of the month is not the same, here is the maximum length of days, according to their business needs, self-extension
function secondFormat ( $ allSec ) { // total number of seconds $ remainSec = (int) $ allSec ; // read time $ humanTime = '' ; // maximum length of time is the day IF ( $ remainSec > 86400 ) { $ Days = (int) ( $ remainSec / 86400 ); $ remainSec = $ remainSec % 86400 ; $ humanTime . = $ Days . 'Days' ; } // 判断小时 if($remainSec > 3600) { $hours = (int)($remainSec / 3600); $remainSec = $remainSec % 3600; $humanTime .= $hours.'时'; } // 判断分钟 if($remainSec > 60) { $minutes = (int)($remainSec / 60); $remainSec = $remainSec % 60; $humanTime .= $minutes.'分'; } // Analyzing second IF ( $ remainSec > 0 ) { $ seconds The = $ remainSec ; $ humanTime . = $ Seconds The . 'S' ; } return $ humanTime ?? '[moments]' ; }