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

Is it possible to protect special characters in a query string?

544


How is session id stored in browser?

557


What is the functionality of the functions strstr() and stristr()?

529


What is the current stable version of php? What advance thing in php7?

521


Why do we use htaccess

634






What are the uses of php language?

539


What is the difference between require_once and require in php?

561


What is http get and post?

535


What is the difference between array_map () and array_shift ()?

519


how to open & closing opening period in fico

1219


How to join multiple strings stored in an array into a single string?

514


What is explode() in php?

542


Which escape sequences can be used in single quoted strings in php?

527


Which is better mysql or sql?

530


What does $_ post mean in php?

596