王尘宇王尘宇

研究百度干SEO做推广变成一个被互联网搞的人

Typecho 相似微博上几分钟前、几天前

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论坛


相关文章

评论列表

发表评论:
验证码

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。