title: change Php date in days ago
body: <p>I am using a component on Joumla that returns dates in this format: 2 months and 6 days ago. 
  But I need the date to be displayed like this:
  xx seconds ago
  or xx minutes ago
  or xx hours ago
  or xx days ago. </p>
  
  <p>The developer told me I have to modify this code, but I am completely new to Php. I tried all day today for over 12 hours in a row, and all I was successfully accomplish was to breakdown my site.</p>
  
  <p>So Could anyone give me help with this. I am willing to grant FTP access if is need. this is the code:</p>
  
  <pre><code>function dateFormatFromTo($from, $to = null)
   {
      $par = JComponentHelper::getParams( 'com_djclassifieds' );      
      $to = (($to === null) ? (time()) : ($to));
      $to = ((is_int($to)) ? ($to) : (strtotime($to)));
      $from = ((is_int($from)) ? ($from) : (strtotime($from)));
      $output = '';     
      $limit = $par-&gt;get('date_format_ago_limit','2');
      $units = array
      (
         "COM_DJCLASSIFIEDS_DATE_YEAR"   =&gt; 29030400, 
         "COM_DJCLASSIFIEDS_DATE_MONTH"  =&gt; 2419200,  
         "COM_DJCLASSIFIEDS_DATE_WEEK"   =&gt; 604800,   
         "COM_DJCLASSIFIEDS_DATE_DAY"    =&gt; 86400,    
         "COM_DJCLASSIFIEDS_DATE_HOUR"   =&gt; 3600,     
         "COM_DJCLASSIFIEDS_DATE_MINUTE" =&gt; 60,       
         "COM_DJCLASSIFIEDS_DATE_SECOND" =&gt; 1         
      );
  
      $diff = abs($from - $to);
      $suffix = (($from &gt; $to) ? (JTEXT::_('COM_DJCLASSIFIEDS_DATE_FROM_NOW')) : (JTEXT::_('COM_DJCLASSIFIEDS_DATE_AGO')));
  
      $i=0;
          foreach($units as $unit =&gt; $mult){
              if($diff &gt;= $mult){
                  if($i==$limit-1 &amp;&amp; $i&gt;0){
                      $output .= " ".JTEXT::_('COM_DJCLASSIFIEDS_DATE_AND').' '.intval($diff / $mult)." ";
                  }else{
                      $output .= ", ".intval($diff / $mult)." ";
                  }   
                  //$and = (($mult != 1) ? ("") : (JTEXT::_('COM_DJCLASSIFIEDS_DATE_AND')));
                  //$output .= ", ".$and.intval($diff / $mult)." ";
                  if(intval($diff / $mult) == 1){
                      $output .= JTEXT::_($unit); 
                  }else{
                      $output .= JTEXT::_($unit."S");
                  }
  
                  $diff -= intval($diff / $mult) * $mult;
                  $i++;
                  if($i==$limit){ break; }            
              }
          }
          $output .= " ".$suffix;
          $output = substr($output, strlen(", "));
    return $output;
   }
  </code></pre>
  
  <p>So, I would greatly appreciate if someone can help me out. I can give FTP access if needed. 
  I have Php 5.3</p>
  
  <p>Thank</p>