Typecho 相似微博上几分钟前、几天前
如许能够完成,在functions.php里增加以下代码:
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'); ?>by muchun @ typecho论坛

评论列表