欢迎您光临自学哈网,只为分享网络知识教程,供大家学习参考!

「自学哈网」帝国cms时间优化(刚刚,几分钟前,几个小时前,几天前)

作者 : 自学哈 本文共452个字,预计阅读时间需要2分钟 2022-09-28 共167人阅读
也想出现在这里? 联系我们

 

function formattime($time){
 $minute = date("H:i",$time);
 $hour = date("H:i",$time);
 $alltime = date("Y-m-d",$time);
 $time = time() - $time;
 if ($time < 60) {
 $str = '刚刚 ';
 }
 elseif ($time < 60 * 60) {
 $min = floor($time/60);
 $str = $min.'分钟前 ';
 }
 elseif ($time < 60 * 60 * 24) {
 $h = floor($time/(60*60));
 $str = $h.'小时前 ';
 }
 elseif ($time < 60 * 60 * 24 * 10) {
 $d = floor($time/(60*60*24));
  
   $str = $d.'天前';
  
 }
    else {
 $str = $alltime;
 }
 return $str;
}
?>
日期调用方法:formattime(strtotime('2016-05-13 20:15:32')); 时间戳调用方法:formattime(1423423423); 

自学哈网

本站声明:
本站所有资源来源于网络,分享目的仅供大家学习和交流!如若本站内容侵犯了原著者的合法权益,可联系邮箱976157886@qq.com进行删除。
自学哈专注于免费提供最新的分享知识、网络教程、网络技术的资源分享平台,好资源不私藏,大家一起分享!

自学哈网 » 「自学哈网」帝国cms时间优化(刚刚,几分钟前,几个小时前,几天前)
也想出现在这里? 联系我们
© 2022 Theme by - 自学哈网 & WordPress Theme. All rights reserved 浙ICP备2022016594号