1
Hello, I have the following case I’m with a date in the database saving so: (02-12-2016). The idea would be to take the current date and if it is less than 2 days that the date quoted above does such a thing. I tried to do so:
foreach ($teste as $row) {
$data_validade = $row->data_validade;
echo $data_validade;
$data_atual = date('d-m-Y');
$diferenca = strtotime($data_validade) - strtotime($data_atual);
$dias = floor($diferenca / (60 * 60 * 24));
if ($dias < 2) {
redirect('Painel_voluntario/index/?aviso=4');
} else {
$dados['status_vaga'] = 'Voluntário Desistiu...';
$data = array(
"excluir" => $this->Vaga_model->aceitarOuRecusar($id_vaga, $id_voluntario, $dados)
);
redirect('Painel_voluntario/index/?aviso=3');
}
}
In this case it is even working, but for example if I type a very high date as 29-10-2998, won’t work(is falling in if it is less than two days, which soon is wrong).