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


Please Help Members By Posting Answers For Below Questions

Explain me what is sql injection?

726


What are the disadvantages of php?

712


Which function will suitably replace 'x' if the size of a file needs to be checked? $Size=x(filename);

754


Describe PHP error and logging information?

766


What are the functions used in php?

735


How to pass an argument to a function?

830


How to increase the execution time of a PHP script?

731


What is xss and csrf?

694


What is isset function in php?

825


Is age an interval or ratio?

710


What is laravel php?

778


What is difference between static and constant in php?

720


How long does a php session last for?

783


What percentage of websites use php?

736


What is the correct and the most two common way to start and finish a php block of code?

725