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');
<code>
<blockcode>
<c>
<cpp>
<drupal5>
<drupal6>
<java>
<javascript>
<python>
<ruby>
<foo>
[foo]
Links to specified hosts will have a rel="nofollow" added to them.
More information about formatting options
<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 your Answer