前言
通讯记录需要用到的一个方法,记录下~
方法
/** * 秒转换为天,小时,分钟 * * @param int $second * * @return string */ function secondConversion($second = 0) { $newtime = ‘‘; $d = floor($second / (3600*24)); $h = floor(($second % (3600*24)) / 3600); $m = floor((($second % (3600*24)) % 3600) / 60); if ($d>‘0‘) { if ($h == ‘0‘ && $m == ‘0‘) { $newtime= $d.‘天‘; } else { $newtime= $d.‘天‘.$h.‘小时‘.$m.‘分‘; } } else { if ($h!=‘0‘) { if ($m == ‘0‘) { $newtime= $h.‘小时‘; } else { $newtime= $h.‘小时‘.$m.‘分‘; } } else { $newtime= $m.‘分‘; } } return $newtime; }
原文地址:https://www.cnblogs.com/wangyang0210/p/10789597.html
时间: 2024-10-10 02:48:54