2
Guys I’m trying to check the difference in days, based on 2 dates.
Well my code is like this:
$data_inicio = new DateTime("2016-07-10");
$data_fim = new DateTime("2016-07-13");
// Resgata diferença entre as datas
$dateInterval = $data_inicio->diff($data_fim);
$dias = $dateInterval->d + ($dateInterval->y * 12);
echo $dias;
Good if I inform the following values:
$data_inicio = new DateTime("2016-07-10");
$data_fim = new DateTime("2016-07-13");
My return and 3, so far so good. But when I put:
$data_inicio = new DateTime("2016-07-10");
$data_fim = new DateTime("2017-08-13");
My return continues to be 3, ie the system ignored the months and years. Someone knows how to solve this?
Thanks @Ricardo Mota, simple and direct, helped me a lot, thanks.
– adventistapr
Boy, you saved my day, thanks @Ricardo Mota
– adventistapr