3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php function getAge($dob) { $dob = strtotime($dob); $y = date('Y', $dob); if (($m = (date('m') - date('m', $dob))) < 0) { $y++; } elseif ($m == 0 && date('d') - date('d', $dob) < 0) { $y++; } return date('Y') - $y; } /*** a date before 1970 ***/ $dob = "April 20 1961"; /*** another date ***/ $tdate = "21-04-2009"; /*** show the date ***/ echo getAge( $dob, $tdate );
based on N3Lmb
Output for 4.3.0 - 7.2.6
54