I need some help with a regular expressions. I'm trying to validate if a string looks like 'yyyy-mm-dd', this is my code so far:
case "date":
if (preg_match("/^[0-9\-]/i",$value)){
$date = explode("-",$value);
$year = $date[0];
$month = $date[1];
$day = $date[2];
if (!checkdate($month,$day,$year))
{
$this->errors[] = "Ogiltigt datum.";
}
} else {
$this->errors[] = "Ogiltigt datum angivet.";
}
break;
I am very new to regular expressions, thanks.