I am trying to figure out what data was stored in db in 5 minutes.
SELECT COUNT(id), DATE_FORMAT(`timestamp`, '%Y-%m-%d %H:%i') FROM `table` WHERE `timestamp` >= CURRENT_TIMESTAMP - INTERVAL 5 MINUTE
timestamp is a unix timestamp (milliseconds since 1970).
not working, I get null num_rows instead of 0, and if I use
if (!isset($resultHistory->num_rows) || !$resultHistory->num_rows)
to perform actions, the code is not included in the loop.
I also tried
SELECT COUNT(id), DATE_FORMAT(`timestamp`, '%Y-%m-%d %H:%i') FROM `table` WHERE DATE_FORMAT(`timestamp`, '%Y-%m-%d %H:%i') >= CURRENT_TIMESTAMP - INTERVAL 5 MINUTE
source share