I am using this code to exclude schedules with dates and times already passed in relation to the current time.
<?php
while($res = mysql_fetch_array($select_agenda)){
$id = $res['id'];
$nome = $res['nome'];
$tel = $res['tel'];
$cel = $res['cel'];
$email = $res['email'];
$plano = $res['plano'];
$data = $res['data'];
$horas = $res['horas'];
$tempo = date("d/m/Y H:i:s",time()-86400);
$sql = mysql_query("DELETE FROM agendar WHERE data < '$tempo'");
?>
Knowing that 86400 refers to the number of seconds of a day, I'm using the above code, and excluding the past schedules for the current time, at the turn of dates.
Following this reasoning, I changed it to -1800, so that the files were deleted every 30 minutes. Staying like this:
$tempo = date("d/m/Y H:i:s",time()-1800);
$sql = mysql_query("DELETE FROM agendar WHERE data < '$tempo'");
But in this way you are deleting all records, not the last 30 minutes of real time.
Schedules are made at 30-minute intervals.
If friends can help me with how to proceed so that the schedules are deleted every 30 minutes, I'll be very grateful.
A big hug to everyone.