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
How to get the number of characters in a string?
Explain the difference b/w static and dynamic websites?
How to get ip address of a server in php?
Explain about looping in PHP?
Will php die?
What are escaping characters?
What are advantages of .htaccess?
How to reset/destroy a cookie?
Is it possible to protect special characters in a query string?
What is "echo" in php?
How to know user has read the email-php?
Is laravel an oop?
Should I learn php before wordpress?
Is rent a variable cost?
Explain what are psrs?