You are making the difference of dates directly, as if they were numbers, and this is not correct.
Make sure that both variables containing date are in the same format.
Then use the Datetime(date) class and make the difference between them.
Then try:
$post_aniversario = '11/05/2000';
$aniversario = new DateTime();
$aniversario = $aniversario->createFromFormat('d/m/Y', $post_aniversario);
$data_atual = new DateTime();
$diff = $aniversario->diff($data_atual);
print_r($diff); // or $diff->days
Upshot:
Dateinterval Object
(
[y] => 0
[m] => 0
[d] => x
[h] => 0
[i] => 0
[s] => 0
[invert] => 0
[days] => x
)
Or still using Datediff
$date1=date_create("2013-03-15");
$date2=date_create("2013-12-12");
$diff=date_diff($date1,$date2);
Explanation date_diff
what’s on line 18?
– RFL
you need to see the number format for subtraction
– MagicHat
Related: https://answall.com/questions/33469/como-comparar-datas-em-php
– MagicHat
Are 2 equal dates ?
– rbz
Other link: https://answall.com/questions/57/howto calculate the difference%C3%A7a-between-two-dates/70
– rbz