通过时间戳获取天、时、分钟
Sonder
2019-08-29
439字
1分钟
浏览 (2.6k)
/**
* str_pad 补零
* @return array
*/
function setTime($sec){
$_seconds = intval($sec);
$seconds = str_pad($_seconds%60,2,'0',STR_PAD_LEFT);
$_mins = intval($_seconds/60);
$_hours = intval($_mins/60);
$hours = str_pad($_hours%24,2,'0',STR_PAD_LEFT);
$day = str_pad(intval($_hours/24),2,'0',STR_PAD_LEFT);
$mins = str_pad($_mins%60,2,'0',STR_PAD_LEFT);
return [$day,$hours,$mins,$seconds];
}