2024年10月24日 建站教程
1、找到include/extend.func.php,在最后面添加
function conversionTime ($time) {
$today = Floor(time()/(3600 * 24));
$senday= Floor($time/(3600 * 24));
$updays = $today-$senday;
if($updays==0)
$str = '今天';
elseif ($updays >=1 && $updays < 31) {
$str = $updays.'天前 ';
}
elseif ($updays >0 && $updays < 1 ) {
$h = floor($updays * 24);
$str = $h.'小时前 ';
}
elseif ($updays >= 31&& $updays < 365) {
$m = floor($updays / 31);
$str = $m.'月前 ';
}
elseif ($updays >= 31&& $updays < 365) {
$y = floor($updays / (31* 365));
$str = $y.'年前 ';
}
else {
$str = $rtime;
}
return $str;
}
2、调用方法
列表页:[field:pubdate function="conversionTime(@me)" /]
内容页:{dede:field.pubdate function="conversionTime(@me)"/}
本文链接:http://so.lmcjl.com/news/16067/