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 me is multiple inheritance supported in php?
What is the difference between Split and Explode in PHP?
Can you explain, when to use if-else if-else over switch statements?
What is the difference between $message and $$message in php?
What is $_ get?
What is mvc php?
Why we use get in php?
Explain what does the unlink() function means?
How can we determine whether a php variable is an instantiated object of a certain class?
What is the difference between php and java?
Why do we use csrf token?
What is the meaning of symbol '$' in jquery?
Explain which cryptographic extension provide generation and verification of digital signatures?
Who is the father or inventor of php?
Is age interval or ordinal?