The source of birthday.php (click to demo the file) viewed 1822 times.
If I wrote this code, then it is licensed under the GPL. If someone else wrote it, then please ask them if you want to use the code.
<?php
function howManyYears($birthday) {
//requires $birthday as yyyy/mm/dd OR yyyy-mm-dd
//and returns the number of years old the person is
$today = date('Ymd');
$birthday = str_replace('/','',$birthday);
$birthday = str_replace('-','',$birthday);
$remainder = $today - $birthday;
$age = floor($remainder / 10000);
return $age;
}
//usage
// birthday.php?birthday=1977-12-07
$birthday = $_GET["birthday"];
echo howManyYears($birthday);
?>
If you want to have a look at the source code, chose a file from this list:
To colour code your own PHP paste it here: