首页 > Typecho 类似微博上几分钟前、几天前 的代码不生效?

Typecho 类似微博上几分钟前、几天前 的代码不生效?

function getDayAgo($date){
$d = new Typecho_Date(Typecho_Date::gmtTime());
$now = $d->format('Y-m-d H:i:s');
$t = strtotime($now) - strtotime($date);
if($t < 60){
return $t . '秒前';
}
if($t < 3600){
return floor($t / 60) .  '分钟前';
}
if($t < 86400){
return floor($t / 3670) . '小时前';
}
if($t < 604800){
return floor($t / 86400) . '天前';
}
if($t < 2419200){
return floor($t / 604800) .  '周前';
}
if($t < 31536000 ){
return floor($t / 2592000 ).'月前';
}

return floor($t / 31536000 ).'年前';

}
调用方法不变,比如在post.php调用文章发布时间:

<?php $this->date('Y-m-d H:i'); ?>

这段代码在最新版的typecho上面不生效是怎么回事啊


我曾经问过的问题,这里有好几种方案。

你看一下。http://.com/q/1010000000650101


查找资料后。。。已搞定

【热门文章】
【热门文章】