This blog is all about deleting rows older than 5 min from the MySQL database.
1 2 3 4 5 6 7 8 9 10 | <?php include 'dbconnect.php'; date_default_timezone_set('Asia/Kolkata'); $dt = date("Y-m-d h:i:s"); $users ="DELETE FROM `otp_verification` WHERE `created_date` < ('" . date("Y-m-d H:i:s"). "' - INTERVAL 5 MINUTE)"; $result = mysqli_query($conn, $users); ?> |
Here otp_verification is Table and DateTime column is created_date
If you want to run this query using cron jobs then click here to learn this.