I am trying to make a report that shows all the loans made in the last day. The time is saved as a time stamp in the database onloan and is saved in the format yyyy-mm-dd 00:00:00. The code I have so far is shown below but i cannot get the time formatted correctly and -1 day.
$yday = mktime(0, 0, 0, date("m") , date("d")-1, date("Y"));
$query = "SELECT *
FROM onloan
WHERE (time > $yday)";
Thanks in advance for any help!
You want to use strtotime()
.
Try $yday = date('Y-m-d h:i:s', strtotime("-1 day"))
Try
SELECT *
FROM onloan
WHERE DATE(Time) = DATE(CAST(NOW() - INTERVAL 1 DAY AS DATE))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With