I have birthdate in php standard format.. How do I find age for the date?
<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
$age=age('2-09-1950');
Following age function may help.
<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');
?>
Read »Category: Tags: