You are here:
» PHP How To Find Age?
PHP How to find age?
This Comment will be submitted for moderation and will not be accessible to other users until it has been approved.
I have birthdate in php standard format.. How do I find age for the date?
Created by programmer

2 years 16 weeks ago
Tags:
<php>
<?php
function age($date_of_birth){
$dob =date('Y-m-d', strtotime($date_of_birth));
$age = date('Y') - date('Y', strtotime($dob));
if (date('md') < date('md', strtotime($dob))) {
$age--;
}
return $age;
}
?>
</php>
Therefore, as an example:
See the example below to use the function
<php>
<?php
$age=age('2-09-1950');
?>
Post Comment