You are here

Calculate age based on date of birth with PHP

<?php
# object oriented
$from = new DateTime('1972-12-11');
$to   = new DateTime('today');
echo
$from->diff($to)->y, "\n";
?>
code type: