- time: documentation ( source)
- strtotime: documentation ( source)
<?php
$year = 1999;
$month = 2;
$day = 6;
$birthday = $month.$day.$year;
// validate birthday
function validateAge($birthday, $age = 25)
{
// $birthday can be UNIX_TIMESTAMP or just a string-date.
if(is_string($birthday)) {
$birthday = strtotime($birthday);
echo "OLDER THAN 25!!!";
}
// check
// 31536000 is the number of seconds in a 365 days year.
if(time() - $birthday < $age * 31536000) {
echo "NOT OLDER THAN 25!!!";
return false;
}
return true;
}