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 about PHP cookies?
What does a special set of tags do in php?
How to create and destroy cookies in php?
What is difference between web service and api?
What is the difference between $name and $$name?
How check field is empty or not in php?
What is the difference between explode() and split() functions?
Write a program to display reverse of any number?
Difference between mysql_connect and mysql_pconnect?
What are php libraries?
Is php used in 2019?
What is constructors and destructors?
What are access specifiers?
What is php call function?
Explain a resource?