[Solved] How to get user date of birth from a form then get the user age in php mysql


PHP >= 5.3.0

# object oriented
$from = new DateTime('1970-02-01');
$to   = new DateTime('today');
echo $from->diff($to)->y;

# procedural
echo date_diff(date_create('1970-02-01'), date_create('today'))->y;

demo

functions: date_create(), date_diff()

solved How to get user date of birth from a form then get the user age in php mysql