直接上代码:
<?php
/
function:显示某一个时间相当于当前时间在多少秒前,多少分钟前,多少小时前
timeInt:unix time时间戳
format:时间显示格式
*/
function timeFormat($timeInt,$format='Y-m-d H:i:s'){
if(empty($timeInt)||!is_numeric($timeInt)||!$timeInt){
return '';
}
$d=time()-$timeInt;
if($d<0){
return '';
}else{
if($d<60){
return $d.'秒前';
}else{
if($d<3600){
return floor($d/60).'分钟前';
}else{
if($d<86400){
return floor($d/3600).'小时前';
}else{
if($d<259200){//3天内
return floor($d/86400).'天前';
}else{
return date($format,$timeInt);
}
}
}
}
}
}
點擊查看更多內容
為 TA 點贊
評論
評論
共同學習,寫下你的評論
評論加載中...
作者其他優質文章
正在加載中
感謝您的支持,我會繼續努力的~
掃碼打賞,你說多少就多少
贊賞金額會直接到老師賬戶
支付方式
打開微信掃一掃,即可進行掃碼打賞哦