title: Converting timestamp to time ago in PHP e.g 1 day ago, 2 days ago...
body: <p>I am trying to convert a timestamp of the format <code>2009-09-12 20:57:19</code> and turn it into something like <code>3 minutes ago</code> with PHP.</p>
  
  <p>I found a useful script to do this, but I think it's looking for a different format to be used as the time variable. The script I'm wanting to modify to work with this format is:</p>
  
  <pre><code>function _ago($tm,$rcs = 0) {
      $cur_tm = time(); 
      $dif = $cur_tm-$tm;
      $pds = array('second','minute','hour','day','week','month','year','decade');
      $lngh = array(1,60,3600,86400,604800,2630880,31570560,315705600);
  
      for($v = sizeof($lngh)-1; ($v &gt;= 0)&amp;&amp;(($no = $dif/$lngh[$v])&lt;=1); $v--); if($v &lt; 0) $v = 0; $_tm = $cur_tm-($dif%$lngh[$v]);
          $no = floor($no);
          if($no &lt;&gt; 1)
              $pds[$v] .='s';
          $x = sprintf("%d %s ",$no,$pds[$v]);
          if(($rcs == 1)&amp;&amp;($v &gt;= 1)&amp;&amp;(($cur_tm-$_tm) &gt; 0))
              $x .= time_ago($_tm);
          return $x;
      }
  </code></pre>
  
  <p>I think on those first few lines the script is trying to do something that looks like this (different date format math):</p>
  
  <pre><code>$dif = 1252809479 - 2009-09-12 20:57:19;
  </code></pre>
  
  <p>How would I go about converting my timestamp into that (unix?) format?</p>