Validate date of birth (DOB) for minimum age limit in php function. This simple php scripts in validating age limit for a registration in sites for legal reasons where users with greater age only allowed to register.
function validateMinimumAgeLimit( $dob, $min_age=18 ) {
$dob = new DateTime( $dob );
$min_age = new DateTime( 'now - ' . $min_age . 'years' );
return $dob <= $min_age;
}
function validateMinimumAgeLimit( $dob, $min_age=18 ) {
$dob = new DateTime( $dob );
$min_age = new DateTime( 'now - ' . $min_age . 'years' );
return $dob <= $min_age;
}
No comments:
Post a Comment