What would be a properway to use TIMEDIFF in the following script? I have column in database that does CURRENT_TIMESTAMP, Now I have it displayed in a table on a page, but I also need another table where the difference in days and hour is counted.
Currently it will echo all results in from that database, I need it to echo the time diff for each now separate.
Can someone please help me implement a correct script in to this:
<html>
<body>
<center>
<table>
<tr>
<td align="center"> Current</td>
<?php
mysql_connect("localhost","root","");//database connection
mysql_select_db("beyondmotors");
$result = mysql_query("SELECT * FROM currentrentals");
echo "<table border='2'>
<tr>
<th>ID</th>
<th>Year</th>
<th>Make</th>
<th>Model</th>
<th>First Name</th>
<th>Last Name</th>
<th>Insurance</th>
<th>Date</th>
<th>Notes</th>
</tr>";
while($row = mysql_fetch_array($result))
{
echo "<tr>";
echo "<td>" . $row['id'] . "</td>";
echo "<td>" . $row['year'] . "</td>";
echo "<td>" . $row['make'] . "</td>";
echo "<td>" . $row['model'] . "</td>";
echo "<td>" . $row['firstname'] . "</td>";
echo "<td>" . $row['lastname'] . "</td>";
echo "<td>" . $row['insurance'] . "</td>";
echo "<td>" . $row['date'] . "</td>";
echo "<td>" . $row['notes'] . "</td>";
echo ("<td><a href=\"edit_form.php?id=$row[id]\">Edit</a></td></tr>");
echo "</tr>";
}
echo "</table>";
I was recommended to do:
SELECT (fields), UNIX_TIMESTAMP(date) as date FROM currentrentals
Than use:
$timesince = date(format, time() - $row['date']);
but i'm having trouble to get that working