How to create the PHP Script to Calculate the Age Using the
Inputs Of our Birth date and the Current date?
Answer Posted / king
<?php
//calculate years of age (input string: YYYY-MM-DD)
function birthday ($birthday){
list($year,$month,$day) = explode("-",$birthday);
$year_diff = date("Y") - $year;
$month_diff = date("m") - $month;
$day_diff = date("d") - $day;
if ($day_diff < 0 || $month_diff < 0)
$year_diff--;
return $year_diff;
}
?>
| Is This Answer Correct ? | 6 Yes | 8 No |
Post New Answer View All Answers
How to process the uploaded files?
Explain PHP looping?
Which is better mysql or sql?
What are the advantages of indexes in php?
What library is used for pdf in php?
How can we automatically escape incoming data?
What is the meaning of ‘escaping to php’?
What are the advantages and disadvantages of cascade style sheets?
What is difference between core php and framework?
How can I find my php version?
How to check a variable is array or not in php?
What is difference between ksort() and usort() functions.
What is php and its features?
What does the array operator '===' means?
How can we execute a php script using command line?