PHP Time axis function code: PHP Date Generation timeline Implementation code

Source: Internet
Author: User
Tags idate
PHP how to generate a date timeline, PHP, a date function of the application instance, the Unix timestamp into the timeline, through this example can grasp the use of the date function.

Example, PHP time axis function code.

Copy Codecode 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;//case before the day before (2 = = $days): $message = ' The day before yesterday '. Date (' H:i ', $time); Break;//7 days case (7 > $days): $message = $days. ' days ago '; break;//more than 7 days default: $message = Date (' N-month J-day H:i ', $time); return $message;}
  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.