PHP determination period has much time has passed

. 1      / * *
 2       *
 . 3       * @param timestamp Time $ input time
 . 4       * @return STR $ STR input time difference between the current time and the Chinese
 . 5       * / 
. 6      function wordTime ( $ Time ) {
 . 7  //         the dump ($ Time); Die ; 
. 8          $ Time = (int) substr ( $ Time , 0, 10 );
 . 9          $ int = Time () - $ Time ;
 10          $ STR = '' ;
 . 11          IF ( $ int <= 2 ) {
 12 is              $ STR= Sprintf ( 'just', $ int );
 13 is          } ELSEIF ( $ int <60 ) {
 14              $ STR = sprintf ( '% D seconds ago', $ int );
 15          } ELSEIF ( $ int <3600 ) {
 16              $ STR = sprintf ( '% D minutes ago ", Floor ( $ int / 60 ));
 . 17          } ELSEIF ( $ int <86400 ) {
 18 is              $ STR = sprintf ('% D hours ago ',floor($int / 3600));
19         } elseif ($int < 2592000) {
20             $str = sprintf('%d天前', floor($int / 86400));
21         } else {
22             $str = date('Y-m-d H:i:s', $time);
23         }
24         return $str;
25     }

 

Guess you like

Origin www.cnblogs.com/luojie-/p/11294892.html