大家都知道,
PHP顯示文章發布時間程式碼範例:
- < ?php
- function format_date($dateStr) {
- $limit = time() - strtotime($dateStr);
- $r = "";
- if($limit < 60) {
- $r = '剛剛';
- } elseif($limit >= 60 && $limit
< 3600) {
- $r = floor($limit / 60) . '分鐘前';
- } elseif($limit >= 3600 && $limit
< 86400) {
- $r = floor($limit / 3600) . '小時前';
- } elseif($limit >= 86400 && $limit
< 2592000) {
- $r = floor($limit / 86400) . '天前';
- } elseif($limit >= 2592000 && $limit
< 31104000) {
- $r = floor($limit / 2592000) . '個月前';
- } else {
- $r = "很久前";
- }
- return $r . "(" . $dateStr . ")";
- }
- echo "發表於:" . format_date
("2009-11-25 23:40");
- ?>
以上這段代碼就是PHP顯示文章發布時間的具體實現方法介紹。
http://www.bkjia.com/PHPjc/445990.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/445990.htmlTechArticle大家都知道, PHP顯示文章發布時間程式碼範例: ?php functionformat_date($dateStr){ $ limit = time ()-strtotime($dateStr); $ r = ; if($limit 60 ){ $ r = '剛剛' ; }e...