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
What is difference Between PHP 5 and 7?
Which is better session or cookie?
Is php better than python?
What are php functions?
What is rtrim php?
What is the difference between array_pop() and array_push()?
Explain what are some new features introduced in php7?
What is the difference between unset and unlink?
Why php was called as personal home page?
What is in a cookie?
Why do you need php?
What are the advantages of php mysql?
Which character is used to match exactly one character?
What is the function mysql_pconnect() useful for?
Why constructor is not overridden?