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
Post a Comment