演示链接:查看演示

DEDECMS后台会员消费记录人性化时间显示不准的解决方法

EDECMS的后台会员消费记录存在BUG,在消费时间后边跟随的人性化时间不准确,一年前的单子也显示几天前。需要进行修改。

 

1、打开include/helpers/time.helper.php,找到

 

 

01 function FloorTime($seconds) 02     { 03         $times ''; 04         $days = floor(($seconds/86400)%30); 05         $hours = floor(($seconds/3600)%24); 06         $minutes = floor(($seconds/60)%60); 07         $seconds = floor($seconds%60); 08         if($seconds >= 1) $times .= $seconds.'秒'; 09         if($minutes >= 1) $times = $minutes.'分钟 '.$times; 10         if($hours >= 1) $times = $hours.'小时 '.$times; 11         if($days >= 1)  $times = $days.'天'; 12         if($days > 30) return false; 13         $times .= '前'; 14         return str_replace(" "'', $times); 15     }

替换为以下代码即可:

 

 

01 function FloorTime($date) { 02 $str = ''; 03 $timer = $date; 04 $diff = $_SERVER['REQUEST_TIME'] - $timer; 05 $day = floor($diff / 86400); 06 $free = $diff % 86400; 07 if($day > 0) { 08 return $day."天前"; 09 }else{ 10 if($free>0){ 11 $hour = floor($free / 3600); 12 $free = $free % 3600; 13 if($hour>0){ 14 return $hour."小时前"; 15 }else{ 16 if($free>0){ 17 $min = floor($free / 60); 18 $free = $free % 60; 19 if($min>0){ 20 return $min."分钟前"; 21 }else{ 22 if($free>0){ 23 return $free."秒前"; 24 }else{ 25 return '刚刚'; 26 } 27 } 28 }else{ 29 return '刚刚'; 30 } 31 } 32 }else{ 33 return '刚刚'; 34 } 35 } 36 }

 

 

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>)

 

更改完毕。
 

THE END
喜欢就支持一下吧
点赞0 分享