How to correctly implement PHP to display article publishing time_PHP tutorial
WBOYOriginal
2016-07-15 13:34:331418browse
As we all know,
PHP display article publishing time code example:
< ?php
function format_date($dateStr) {
$limit = time() - strtotime($dateStr);
$r = ""; 🎜>
60
) { $r = 'just'
;
} elseif($limit >= 60 && $limit
<3600 ) { $r = floor
($limit / 60) . 'minutes ago';
} elseif($limit >= 3600 && $limit
<86400 ) { $r = floor
($limit / 3600) . 'hours ago';
} elseif($limit >= 86400 && $limit
<2592000 ) { $r = floor
($limit / 86400) . 'days ago';
} elseif($limit >= 2592000 && $limit
<31104000 ) { $r = floor
($limit / 2592000) . 'months ago' ;
} else { $r =
"A long time ago"
;
} return $r . "(" . $dateStr . ")"; }
echo "Posted on: " . format_date
(" 2009-11-25 23:40");
?>
The above code is an introduction to the specific implementation method of displaying the article publishing time in PHP.
http://www.bkjia.com/PHPjc/445990.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/445990.htmlTechArticleAs we all know, PHP code example for displaying article publishing time: ?php functionformat_date($dateStr){ $ limit = time ()-strtotime($dateStr); $ r = ; if($limit 60 ){ $ r = 'just' ; }e...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn