🔥码云GVP开源项目 12k star Uniapp+ElementUI 功能强大 支持多语言、二开方便! 广告
~~~ /** * Function dataformat * 时间转换(将秒转换为时间) * @param $n INT时间 */ function dataformat($n) { $hours = floor($n/3600); $minite = floor($n%3600/60); $secend = floor($n%3600%60); $minite = $minite < 10 ? "0".$minite : $minite; $secend = $secend < 10 ? "0".$secend : $secend; if($n >= 3600){ return $hours."时".$minite."分".$secend."秒"; }else{ return "0时".$minite."分".$secend."秒"; } } ~~~ ~~~ /** * 获取秒数对应的时间 * @param int $second * @return array */ function secondConversionArray($second = 0) { $d = floor($second / (3600 * 24)); $h = floor(($second % (3600 * 24)) / 3600); $m = floor((($second % (3600 * 24)) % 3600) / 60); $s = floor((($second % (3600 * 24)) % 3600) % 60); $newtime = [ 'day' => $d, 'hour' => $h, 'minute' => $m, 'second' => $s ]; return $newtime; } ~~~