title: Get time from MySQL timestamp and show in hours, minutes etc?
body: <p>I'm trying to echo the <code>timestamp</code> in MySQL as seconds, minutes, days etc.</p>
  
  <p>The script was working fine but I've had to tidy my code up a bit and now it won't get the time; it just echos out <code>0 days</code> or <code>0 hours</code> or <code>0 whatever</code>. </p>
  
  <p>This is how it was before I touched the time code but I couldn't have it like this because I've had to edit some <code>div</code> orders.</p>
  
  <p>So my question is please can someone tell me or show me what I've done for it to stop working? thank you</p>
  
  <p>How it was before:</p>
  
  <pre><code>&lt;div class="board-wall-feeds"&gt;        
  &lt;div class="social_header"&gt;
  &lt;?php echo "$profile[2]" ?&gt;'s News &amp; Updates:
  &lt;/div&gt;        
  &lt;?php
  $timeline_set = get_timeline();
  while ($news = mysql_fetch_array($timeline_set)) { 
  echo "
  
  &lt;div class=\"news_feeds_board_text\"&gt;{$news['content']}
  &lt;div class=\"social_footer\"&gt;&lt;a href=\"../../../delete_news_post.php?to=".$news['id']."&lt;/div&gt;&lt;div class=\"social_clip\"&gt;&lt;/div&gt;&lt;/a&gt;"; ?&gt;
  
  
          &lt;?
          $datetime1 = new DateTime();
          $datetime2 = new DateTime ($news['date_added']);
          $interval = $datetime1-&gt;diff($datetime2);
          $mdhms = explode('-',$interval-&gt;format('%m-%d-%H-%i-%s'));
  
  $labels = Array(' months', ' days', ' hours', ' minutes', ' seconds');
  $i = 0;
  foreach($mdhms as $t){
    if($t &gt; 0) break;
    $i+=1;
  }
  
          echo "about ".$t.$labels[$i]." ago"; ?&gt;&lt;/div&gt;&lt;/div&gt;
          &lt;? } ?&gt;
  </code></pre>
  
  <p>How it is now with my new <code>div</code> order:</p>
  
  <pre><code> &lt;div class="board-wall-feeds"&gt;        
  &lt;div class="social_header"&gt;
  &lt;?php echo "$profile[2]" ?&gt;'s News &amp; Updates:
  &lt;/div&gt;        
  &lt;?php
  
  
          $datetime1 = new DateTime();
          $datetime2 = new DateTime ($news['date_added']);
          $interval = $datetime1-&gt;diff($datetime2);
          $mdhms = explode('-',$interval-&gt;format('%m-%d-%H-%i-%s'));
  
  $labels = Array(' months', ' days', ' hours', ' minutes', ' seconds');
  $i = 0;
  foreach($mdhms as $t){
    if($t &gt; 0) break;
    $i+=1;
  }
  
  
  
  $timeline_set = get_timeline();
  while ($news = mysql_fetch_array($timeline_set)) { 
  echo "
  
  &lt;div class=\"news_feeds_board_text\"&gt;{$news['content']}
  &lt;div class=\"social_footer\"&gt;about ".$t.$labels[$i]." ago&lt;a href=\"../../../delete_news_post.php?to=".$news['id']."&lt;/div&gt;&lt;div class=\"social_clip\"&gt;&lt;/div&gt;&lt;/div&gt;&lt;/a&gt;"; ?&gt;
  
  
          &lt;? } ?&gt;
          &lt;/div&gt;
  </code></pre>