Age Calculator in PHP
Age Calculator in PHP
Write a PHP Program code to calculate and show the current age of a person.
Sample date of birth: 3.1.2021
Sample Solution:
1 2 3 4 5 6 7 | <?php $BirthDay = new DateTime('3.10.2021'); // Your birthday $Recent_Today = new Datetime(date('m.d.y')); $differnce = $Recent_Today->diff($BirthDay); printf(' Your age till date : %d years, %d month, %d days', $differnce->y, $differnce->m, $differnce->d); printf("\n"); ?> |