Birthdate validation for less than 18 in PHP
Here is the code to validate for birthdate,
//Validate for users below 18 only
function birthdate($then, $min)
{
// $then will first be a string-date
$then = strtotime($then);
//The age to be less than 18
$min = strtotime('+18 years', $then);
if(time() < $min)
{
return false;
}
else {
return true;
}
}
//Validate for users below 18 only
function birthdate($then, $min)
{
// $then will first be a string-date
$then = strtotime($then);
//The age to be less than 18
$min = strtotime('+18 years', $then);
if(time() < $min)
{
return false;
}
else {
return true;
}
}
Comments
Post a Comment