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
Explain php parameterized functions.
"mysql_fetch_row — Get a result row as an enumerated array",this sentence comes from the PHP offical manual.However ,i can not understand the words "enumerated array".I need some help.Thanks a lot to everyone that reply.
How to set session.gc_divisor properly?
Where do I run php code?
Explain the purpose of output buffering in php.
What is the functionality of the functions strstr() and stristr()?
Tell me how comparison of objects is done in php5?
Do I need apache for php?
Do you know how can we check the value of a given variable is a number?
What does php mean?
What is "print" in php?
How to get no. of rows using MYSQL function?
How to do single and multi line comment in php?
Is php used for frontend or backend?
What is an associative array?