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;
  }
}

Comments

Popular posts from this blog

Ghostscript Installation and Configuration in Windows 7

Joomla - Get user id