title: php time function works then stop working
body: <p>So i found this code from the link bellow and it worked fine like 2 days ago but then just stops working. when i gave it the time from mysql CURRENT TIMESTAMP it just outputs 8, 7 or 6 hours no matter how long it has been. if anyone knows how to improve this or a better way to do the function please submit it here or give me a link to it. I have tried it on php 5.6 and php 7 but neither fix it.</p>
  
  <p>example:</p>
  
  <p>$time = 2017-09-11 17:10:51</p>
  
  <p>input:</p>
  
  <p>time_elapsed_string($time);</p>
  
  <p>output:</p>
  
  <p>5 hours ago</p>
  
  <pre><code>#function from https://stackoverflow.com/questions/1416697/converting-timestamp-to-time-ago-in-php-e-g-1-day-ago-2-days-ago
  function time_elapsed_string($datetime, $full = false) {
      $now = new DateTime;
      $ago = new DateTime($datetime);
      $diff = $now-&gt;diff($ago);
  
      $diff-&gt;w = floor($diff-&gt;d / 7);
      $diff-&gt;d -= $diff-&gt;w * 7;
  
      $string = array(
          'y' =&gt; 'year',
          'm' =&gt; 'month',
          'w' =&gt; 'week',
          'd' =&gt; 'day',
          'h' =&gt; 'hour',
          'i' =&gt; 'minute',
          's' =&gt; 'second',
      );
      foreach ($string as $k =&gt; &amp;$v) {
          if ($diff-&gt;$k) {
              $v = $diff-&gt;$k . ' ' . $v . ($diff-&gt;$k &gt; 1 ? 's' : '');
          } else {
              unset($string[$k]);
          }
      }
  
      if (!$full) $string = array_slice($string, 0, 1);
      return $string ? implode(', ', $string) . ' ago' : 'just now';
  }
  </code></pre>