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 what is sql injection?
What are the disadvantages of php?
Which function will suitably replace 'x' if the size of a file needs to be checked? $Size=x(filename);
Describe PHP error and logging information?
What are the functions used in php?
How to pass an argument to a function?
How to increase the execution time of a PHP script?
What is xss and csrf?
What is isset function in php?
Is age an interval or ratio?
What is laravel php?
What is difference between static and constant in php?
How long does a php session last for?
What percentage of websites use php?
What is the correct and the most two common way to start and finish a php block of code?