if(!function_exists('tranTime'))
{
function tranTime($time)
{
$rtime=date("m-d H:i",$time);
$htime=date("H:i",$time);
$etime=time() - $time;
if ($etime < 1) return '刚刚';
$interval=array (
12 * 30 * 24 * 60 * 60=> ' 年 前',
30 * 24 * 60 * 60=> ' 个 月 前',
7 * 24 * 60 * 60=> ' 周 前',
24 * 60 * 60 => ' 天 前',
60 * 60 => ' 小 时 前',
60 => ' 分 钟 前',
1 => ' 秒 前'
);
foreach($interval as $secs=> $str)
{
$d=$etime / $secs;
if($d >=1)
{
$r=round($d);
return $r . $str;
}
};
}
}
版权声明:本文采用知识共享 署名4.0国际许可协议 [BY-NC-SA] 进行授权
文章名称:《织梦CMS时间格式实现XX秒前、XX分钟前、XX天前》
文章链接:
https://www.umxmt.com/856.html
本站资源仅供个人学习交流,请于下载后24小时内删除,不允许用于商业用途,否则法律问题自行承担。