08-21-2017, 09:51 PM
Here is the validation rule that I use. Feel free to adjust the date format to something else.
Code:
case 'valid_date':
Code:
$d = DateTime::createFromFormat('Y-m-d', $value);
Code:
if(($d && $d->format('Y-m-d') == $value)) $valid = true;
Code:
else $valid = false;
Code:
if ($valid != true) {
Code:
$this->addError(["{$display} must be a date with a format of YYYY-MM-DD.", $item]);
Code:
}
Code:
break;