What are the potential pitfalls of using regular expressions to validate dates in PHP?
Using regular expressions to validate dates in PHP can be error-prone and may not cover all possible date formats. It is better to use PHP's built-in date functions like `strtotime()` or `DateTime::createFromFormat()` to accurately validate dates.
$date = "2022-12-31";
if (strtotime($date) === false) {
echo "Invalid date format";
} else {
echo "Valid date format";
}