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
Do you have to initialize variables in php?
Is php still used?
What is the use of strip_tags() method?
How can you make a connection with mysql server using php?
Why do we use cookie?
Explain scalar type declarations in php7?
Which software is used to run php programs?
What is a static variable in php?
How long is session timeout?
What is a simple php method to make a cross domain data request?
What is the difference server side and browser side validation?
What is the difference between public, protected and private?
Explain the changes in php versions?
Why do we need session?
What is trim codeigniter?