PHP mysql Display Time Ago in Table -


i'm struggling timestamp has been converted time ago displayed within table. i've seen tutorial on how have displayed haven't came across trying table.

<?php  $time = strtotime($tbllobbies['time']); $dbdate = new datetime($time); $currdate = new datetime(); $interval = $currdate->diff($dbdate); echo $interval->h." hours ".$interval->m." minutes ago";  while($tbllobbies=mysql_fetch_assoc($records)) {   echo "<tr>"; echo "<td><a href='".$tbllobbies["formlobbyid"]."'>click here join lobby</a></td>"; echo "<td><a href='".$tbllobbies["formsteamid"]."'>".$tbllobbies["formsteamname"]."</td>"; echo "<td>".$tbllobbies["formyourrank"]."</td>"; echo "<td>".$tbllobbies["formrankgroup"]."</td>"; echo "<td>".$tbllobbies["formlobbytype"]."</td>"; echo "<td><img src='".$tbllobbies['formlocation']."' width=\"32\"></td>"; echo "<td>".$tbllobbies["time"]."</td>"; echo "</tr>";  } //end while ?> 

edit:

i'm looking have interval displayed in table, each row displayed, in

echo "<td>".$tbllobbies["time"]."</td>"; 

i hope helps.

(very new php sorry if find hard understand can't explain well)

edit:

have given own answer below, thank given.

in php, have instantiate variable before can use variable. want more this:

while($tbllobbies=mysql_fetch_assoc($records)) { $time = strtotime($tbllobbies['time']); $currdate = new datetime(); $interval = $currdate->diff($time);  echo "<tr>"; echo "<td><a href='".$tbllobbies["formlobbyid"]."'>click here join lobby</a></td>"; echo "<td><a href='".$tbllobbies["formsteamid"]."'>".$tbllobbies["formsteamname"]."</td>"; echo "<td>".$tbllobbies["formyourrank"]."</td>"; echo "<td>".$tbllobbies["formrankgroup"]."</td>"; echo "<td>".$tbllobbies["formlobbytype"]."</td>"; echo "<td><img src='".$tbllobbies["formlocation"]."' width=\"32\"></td>"; echo "<td>". $interval->format("%h")." hours ".$interval->("%m")." minutes ago"."</td>"; echo "</tr>";  } //end while 

can show sql statement table working on?


Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -