PHP timeline function code: PHP date generation timeline implementation code

WBOY
Release: 2016-07-25 08:51:18
Original
1255 people have browsed it
How does PHP generate a timeline from a date? An application example of the date function in PHP. Generate a unix timestamp into a timeline. Through this example, you can master the usage of the date function.

Example, php timeline function code.

Copy code Code example: $seconds) { $message = 'just'; } else { $message = $seconds . 'seconds ago'; } } $message = intval ( $seconds / 60 ) . 'Minutes ago'; } $message = idate ( 'H', $nowTime ) - idate ( 'H', $time ) . 'Hours ago'; break; //yesterday case (1 == $days): $message = 'yesterday' . date ( 'H:i', $time ); break; //The day before yesterday case (2 == $days): $message = 'The day before yesterday' . date ( 'H:i', $time ); break; //within 7 days case (7 > $days): $message = $days . 'days ago'; break; //More than 7 days default: $message = date ( 'n month j day H:i', $time ); break; } } return $message; }


source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!