How can I compare this datetime from the MySQL database with now?
I sent the date in the database record using the MySQL function now() and was trying to detect records that were more than 30 days old.
if (date_diff($myrow["LastLogin"], time()) > -30) {
}
$myrow["LastLogin"] does contain a valid value since i see it as text. confirmed in the database it’s a “datetime” type.
here’s more of the code.
if ($myrow = mysql_fetch_array($result_set)) {
do {
if (date_diff($myrow["LastLogin"], getdate()) > -30) {
echo "<tr>";
echo "<td>" . $myrow["PCName"] . ' </td>';
echo "<td>" . $myrow["LastLogin"] . ' </td>';
echo "</tr>\n";
}
} while ($myrow = mysql_fetch_array($result_set));
}
thank you!
Do it in your query, not in the code.