<?php $data1 = new DateTime('19910906'); $data2 = new DAteTime('19981205'); $idade = $data1->diff($data2); echo "Idade: " . $idade->y . " anos.<br>";
Standard input is empty
Idade: 7 anos.<br>object(DateInterval)#3 (15) { ["y"]=> int(7) ["m"]=> int(2) ["d"]=> int(29) ["h"]=> int(0) ["i"]=> int(0) ["s"]=> int(0) ["weekday"]=> int(0) ["weekday_behavior"]=> int(0) ["first_last_day_of"]=> int(0) ["invert"]=> int(0) ["days"]=> int(2647) ["special_type"]=> int(0) ["special_amount"]=> int(0) ["have_weekday_relative"]=> int(0) ["have_special_relative"]=> int(0) }