PHP general function, PHP General _php Tutorial

Source: Internet
Author: User
Tags idate

PHP general function, PHP Universal


1 /**2 * Time axis function, Unix timestamp3 * @param int $time time4  */5 functionTrantime ($time) {6     //$time = Strtotime ($time);7     $nowTime= Time (); 8     $message= ''; 9     //a year agoTen     if(Idate(' Y ',$nowTime) !=Idate(' Y ',$time )) { One         $message=Date(' Y year m D Day ',$time ); A     } -     Else { -         //same year the         $days=Idate(' Z ',$nowTime) -Idate(' Z ',$time ); -         Switch(true){ -             //in one day -              Case(0 = =$days): +                 $seconds=$nowTime-$time; -                 //within one hour +                 if($seconds< 3600) { A                     //in a minute . at                     if($seconds< 60) { -                         if(3 >$seconds) { -                             $message= ' Just '; -}Else { -                             $message=$seconds. ' Seconds ago '; -                         } in                     } -                     $message=intval($seconds/60). ' Minutes ago '; to                 } +                 $message=Idate(' H ',$nowTime) -Idate(' H ',$time) . ' Hour ago '; -                  Break; the                 //Yesterday *              Case(1 = =$days): $                 $message= ' Yesterday '.Date(' H:i ',$time );Panax Notoginseng                  Break; -                 //The day before the              Case(2 = =$days): +                 $message= ' The day before yesterday '.Date(' H:i ',$time ); A                  Break; the                 //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 ); the                  Break; -         }Wuyi     } the     return $message; -}

http://www.bkjia.com/PHPjc/969883.html www.bkjia.com true http://www.bkjia.com/PHPjc/969883.html techarticle PHP general functions, PHP Universal 1/* * 2 * Timeline function, Unix timestamp 3 * @param int $time Time 4 */5 function Trantime ($time) {6//$time = STRT Otime ($time); 7 $nowTime = t ...

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