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
Is it possible to protect special characters in a query string?
How is session id stored in browser?
What is the functionality of the functions strstr() and stristr()?
What is the current stable version of php? What advance thing in php7?
Why do we use htaccess
What are the uses of php language?
What is the difference between require_once and require in php?
What is http get and post?
What is the difference between array_map () and array_shift ()?
how to open & closing opening period in fico
How to join multiple strings stored in an array into a single string?
What is explode() in php?
Which escape sequences can be used in single quoted strings in php?
Which is better mysql or sql?
What does $_ post mean in php?