Hello, I have the following case I am having a date in the database saving like this: (02-12-2016) . The idea would be to get the current date and if it is less than 2 days the date quoted above do such 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 still working, but for example if I type a very high date like 29-10-2998 , it will not work (it is falling on if it is less than two days, which is soon wrong).