在dedeCMS後台查看會員消費記錄時發現,在消費時間後邊跟隨的人性化時間一點都不准確,一年前的單子只顯示幾天前。看著很不舒服,於是就修改一下。
1、打開include/helpers/time.helper.php,找到
function FloorTime($seconds)
{
$times = '';
$days = floor(($seconds/86400)%30);
$hours = floor(($seconds/3600)%24);
$minutes = floor(($seconds/60)%60);
$seconds = floor($seconds%60);
if($seconds >= 1) $times .= $seconds.'秒';
if($minutes >= 1) $times = $minutes.'分鐘 '.$times;
if($hours >= 1) $times = $hours.'小時 '.$times;
if($days >= 1) $times = $days.'天';
if($days > 30) return false;
$times .= '前';
return str_replace(" ", '', $times);
}
替換為以下代碼即可:
function FloorTime($date) {
$str = '';
$timer = $date;
$diff = $_SERVER['REQUEST_TIME'] - $timer;
$day = floor($diff / 86400);
$free = $diff % 86400;
if($day > 0) {
return $day."天前";
}else{
if($free>0){
$hour = floor($free / 3600);
$free = $free % 3600;
if($hour>0){
return $hour."小時前";
}else{
if($free>0){
$min = floor($free / 60);
$free = $free % 60;
if($min>0){
return $min."分鐘前";
}else{
if($free>0){
return $free."秒前";
}else{
return '剛剛';
}
}
}else{
return '剛剛';
}
}
}else{
return '剛剛';
}
}
}
2、打開後台管理目錄下的templets/member_operations.htm,找到
(<font color="#FF0000">{dede:field.mtime function="floorTime(time()-@me,@me)"/}</font>)
替換為:
(<font color="#FF0000">{dede:field.mtime function="floorTime(@me)"/}</font>)
更改完畢。
*