Skip to content

Instantly share code, notes, and snippets.

@nirendra
Created November 27, 2013 23:51
Show Gist options
  • Save nirendra/7685085 to your computer and use it in GitHub Desktop.
Save nirendra/7685085 to your computer and use it in GitHub Desktop.
Date format validation in PHP
function checkDateFormat($date)
{
//match the format of the date
if (preg_match ("/^([0-9]{4})-([0-9]{2})-([0-9]{2})$/", $date, $parts))
{
//check weather the date is valid of not
if(checkdate($parts[2],$parts[3],$parts[1]))
return true;
else
return false;
}
else
return false;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment