PHP Time Call related issues

Source: Internet
Author: User
PHP Time Call Issue
Do not understand the PHP programming, ask:
Want to achieve, * minutes ago (* hours ago ...) ), do not know how to compile, find a piece of code on the Internet, very useful, but also very simple:
PHP Code
  
   
  
   ' Year ',           ' 2592000 ' = ' month ',           ' 604800 ' = ' Week ', '           86400 ' and ' Day ',           ' 3600 ' = ' ' hours ',           ' x ' and ' Minutes ',           ' 1 ' = ' s '      );         foreach ($f as $k = + $v)       {                   if (0! = $c =floor ($t/(int) $k))           {               return $c. $v. ' ago ';           }   }   echo format_time (' 1336880454 ');   ? >


But here time needs to be converted to a Unix timestamp, and a piece of code is found:
PHP Code
  
   
  
   


Now the code for the page is this:
PHP Code
  
   
  
   
  
   ", Strtotime ($row [" Pay_time "])?>
  
   


Question: Want to integrate the above three code together, achieve what I need, * minutes ago (* hours ago ...) ), how to do?

------Solution--------------------
PHP code
!--? PHP function Format_time ($time) {$t =time       ()-$time; $f =array (' 31536000 ' =--> ' years ', ' 2592000 ' + ' month ', ' 604800 ' + ' Week ', ' 86400 ' + ' Day         ', ' 3600 ' = ' hours ', ' the ' + ' ' minutes ', ' 1 ' = ' s '; foreach ($f as $k = + $v) {if (0! = $c =floor ($t/(int) $k)) {return $c. $v.           ' former '; }}} while ($row = mysql_fetch_array ($rs _tmmsm)) {echo format_time (Strtotime ($row ["pay_time"]);}? 
  • 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.