add date validation

This commit is contained in:
OliiverHacker
2021-05-25 16:35:41 +02:00
parent c1ff4c2d53
commit f52d3a455c
2 changed files with 24 additions and 2 deletions
+16
View File
@@ -416,5 +416,21 @@ class datum
return intval(substr($timestring, 0, 2)) + intval(substr($timestring, 3, 2)) / 60;
}
/**
* Prueft das Datum
* @param $date = string
* @return true wenn ok, sonst false
*/
static public function verifyDate($date, $strict = true)
{
$dateTime = DateTime::createFromFormat('Y-m-d', $date);
if ($strict) {
$errors = DateTime::getLastErrors();
if (!empty($errors['warning_count'])) {
return false;
}
}
return $dateTime !== false;
}
}
?>