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

What is difference Between PHP 5 and 7?

769


Which is better session or cookie?

739


Is php better than python?

739


What are php functions?

767


What is rtrim php?

779


What is the difference between array_pop() and array_push()?

853


Explain what are some new features introduced in php7?

717


What is the difference between unset and unlink?

752


Why php was called as personal home page?

760


What is in a cookie?

743


Why do you need php?

756


What are the advantages of php mysql?

736


Which character is used to match exactly one character?

775


What is the function mysql_pconnect() useful for?

738


Why constructor is not overridden?

736