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

How to get the number of characters in a string?

559


Explain the difference b/w static and dynamic websites?

488


How to get ip address of a server in php?

539


Explain about looping in PHP?

593


Will php die?

520






What are escaping characters?

534


What are advantages of .htaccess?

523


How to reset/destroy a cookie?

568


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

523


What is "echo" in php?

527


How to know user has read the email-php?

485


Is laravel an oop?

499


Should I learn php before wordpress?

493


Is rent a variable cost?

547


Explain what are psrs?

503