PHP implements a function code that publishes information a few minutes ago

Source: Internet
Author: User
    1. /**
    2. * Published many minutes ago
    3. * Site bbs.it-home.org
    4. */
    5. function CTime ($seconds) {
    6. if ($seconds <60) {
    7. $msg = $seconds. " Seconds ";
    8. }elseif ($seconds <3600) {
    9. $msg = (int) ($seconds/60). " Points ";
    10. }elseif ($seconds <86400) {
    11. $msg = (int) ($seconds/60/60). " Hours ";
    12. }else{
    13. $msg = (int) ($seconds/60/60/24). " Days ";
    14. }
    15. return $msg;
    16. }
    17. ?>
Copy Code

2. Call Method:

    1. $addtime = time ();
    2. $seconds = $addtime-$rswy [' addtime '];
    3. echo CTime ($seconds);
    4. ?>
Copy Code

The above is a simple example of today's PHP tutorial, for beginners to refer to friends.

>>> you may be interested in the article: PHP Implementation time axis function (just, 5 minutes ago) PHP get time, how many minutes before the sample code PHP deleted n minutes ago created a small example of all files PHP based on the time display just, a few minutes ago, a few hours ago implementation code

  • 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.