附代码:
<?php $time_start=time()-86600; $time_diff=time()-$time_start; $date_array=array(‘年‘=>31536000,‘月‘=>2592000,‘周‘=>604800,‘天‘=>86400,‘小时‘=>3600,‘分钟‘=>60,‘秒‘=>1); $real_diff=""; foreach ($date_array as $key => $v) { if ($time_diff>=$v) { //大于当前计量单位的情况下进行单位处理 $num=intval($time_diff/$v);//获取整时/整分/整秒 $time_diff-=$num*$v;//获取减小一级的时间 即时变分 分变秒 $real_diff.=$num.$key;//拼接所得的时分秒结果 } } var_dump($real_diff);exit; ?>
时间: 2024-10-28 10:36:03