2
I am using this code to delete schedules with dates and times already past 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 am using the code above, and excluding the past schedules referring to the current time, at the turn of the dates.
Following this reasoning, I changed to -1800, so that the files were deleted every 30 minutes. Getting like this:
$tempo = date("d/m/Y H:i:s",time()-1800);
$sql = mysql_query("DELETE FROM agendar WHERE data < '$tempo'");
But this way it is excluding all records, and not the last 30 minutes referring to real time.
Scheduling is done at 30-minute intervals.
If friends can give me a help on how I should proceed to schedules being deleted every 30 minutes, I would be very grateful.
Big hug to all.
Hello Allan, thank you so much for your attention to my problem. But I am using a Datepicker where I select the date and write in a column Varchar and not in Datetime, and a Select where I select the times and save in a column also in Varchar, have you show me how to change my code to work with your tip? Hugs.
– Sergio Murilo Cabral
You could concatenate the value of Datepicker and Select to mount a datetime field and write to a suitable field. It would be very practical to use the date as an object, also for sorting with filters as > higher or < lower. What do you think?
– Allan Andrade