How to correctly display the article release time in PHP. As we all know, PHP shows an example of the release time code :? Phpfunctionformat_date ($ dateStr) {$ limittime ()-strtotime ($ dateStr); $ r; if ($ limit60) {$ r just now;} e everyone knows,
PHP shows the article release time code example:
- <? Php
- Function format_date ($ dateStr ){
- $ Limit = time ()-strtotime ($ dateStr );
- $ R = "";
- If ($ limit< 60){
- $ R = 'gang ';
- } Elseif ($ limit>= 60 & $ limit
< 3600){
- $ R = floor ($ limit/60). 'minute ago ';
- } Elseif ($ limit>= 3600 & $ limit
< 86400){
- $ R = floor ($ limit/3600). 'hour ago ';
- } Elseif ($ limit>= 86400 & $ limit
< 2592000){
- $ R = floor ($ limit/86400). 'day before ';
- } Elseif ($ limit>= 2592000 & $ limit
< 31104000){
- $ R = floor ($ limit/2592000). 'months ago ';
- } Else {
- $ R = "long ago ";
- }
- Return $ r. "(". $ dateStr .")";
- }
- Echo "Published on:". format_date
");
- ?>
The above code shows the specific implementation methods for PHP to display the article release time.
Example code for displaying the release time of an article in PHP :? Php functionformat_date ($ dateStr) {$ limit = time ()-strtotime ($ dateStr); $ r =; if ($ limit 60) {$ r = 'gang ';} e...