SELECT * FROM `test_time2` WHERE tm2 = curdate()
Here our tm field stores date data only. If we are storing date and time both then we have to change the query by adding a greater than equal to comparison.
SELECT * FROM `test_time` WHERE tm >= curdate()
This way we can collect records of present date. We can use DATE_SUB() functions to get the records of last 7 days or 15 days or X days.
SELECT * FROM test_time2 WHERE ( unix_timestamp( ) - unix_timestamp( tm ) ) < 5
The above query will return all records updated within last five seconds. This can be changed to X ( any ) seconds.
Author
🎥 Join me live on YouTubePassionate about coding and teaching, I publish practical tutorials on PHP, Python, JavaScript, SQL, and web development. My goal is to make learning simple, engaging, and project‑oriented with real examples and source code.