I am making a system where the user can schedule postings, that is, if he enters the date and time, the post will be released when the current date is equal to inserted, until there logic is simple but I am in trouble to apply this to a function.
I watched a videoaula , but it is very old and uses parameters that I could not use so I adapted the code but anyway does not work.
The function looks like this:
function publicarAgendado(){
date_default_timezone_set('America/Sao_Paulo');
$dataAgora = date('d-m-Y H:i:s');
$selecionar_agendados = @mysqli_query("SELECT * from postagens where status = 0");
while ($PubAgd = @mysqli_fetch_array($selecionar_agendados)) {
$aiai = $PubAgd['id'];
setlocale(LC_TIME,'pt_BR','pt_BR.utf-8','portuguese');
date_default_timezone_set('America/Sao_Paulo');
$data_banco = date('d/m/Y H:i:s', strtotime($PubAgd['agendado']));
if ($data_banco <= $dataAgora) {
$up = mysqli_query("UPDATE postagens SET status=1 where id= $aiai");
}
}
}
In the database the field of this date is as datetime and the HTML is in an input with the datetime-local type. Please help me urgently as I have to submit a preview of this system tomorrow.