Write a PHP script to calculate the current age of a person.
Sample date of birth : 11.4.1987
<?php $bday = new DateTime('11.4.1987'); // Your date of birth $today = new Datetime(date('m.d.y')); $diff = $today->diff($bday); printf(' Your age : %d years, %d month, %d days', $diff->y, $diff->m, $diff->d); printf("\n"); ?>
Sample Output:
Your age : 30 years, 3 month, 0 days
total answers (1)
start bookmarking useful questions and collections and save it into your own study-lists, login now to start creating your own collections.
Sample Output:
need an explanation for this answer? contact us directly to get an explanation for this answer