Is there a nice way to implement timeago with datatables?
Is there a nice way to implement timeago with datatables?
magepvp117
Posts: 1Questions: 1Answers: 0
I currently have a datatable that stores timestamps. I would like to display this in the datatable in the "x seconds ago" format. Here is my table output.
<table id="player_data" class="table table-bordered">
<thead>
<tr>
<td>1</td>
<td>2</td>
<td>3</td>
<td>4</td>
<td>5</td>
<td>Time</td>
</tr>
</thead>
<?php
while($row = mysqli_fetch_array($result))
{
echo '
<tr>
<td>'.$row[ "1"]. '</td>
<td>'.$row[ "2"]. '</td>
<td>'.$row[ "3"]. '</td>
<td>'.$row[ "4"]. '</td>
<td>'.$row[ "5"]. '</td>
<td>'.$row[ "time"]. '</td>
</tr>
';
}
?>
</table>
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
Quick point: You don't have a
tbody
element.Regarding
timeago
, seeing has you are generating the output from PHP you could use(time() - $row['time'])
.Allan
Alternatively, use one of MySQL's date arithmetic functions to return your requirements.
Which would probably be significant more performant. Good suggestion .
Allan