Skip to content

Commit 436fd87

Browse files
committed
fix: valid_date does not work in PHP 8.2
See php/php-src#9431 (comment)
1 parent 69b2f46 commit 436fd87

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

system/Validation/FormatRules.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -344,6 +344,11 @@ public function valid_date(?string $str = null, ?string $format = null): bool
344344
$date = DateTime::createFromFormat($format, $str);
345345
$errors = DateTime::getLastErrors();
346346

347+
// PHP 8.2 or later.
348+
if ($date !== false && $errors === false) {
349+
return true;
350+
}
351+
347352
return $date !== false && $errors !== false && $errors['warning_count'] === 0 && $errors['error_count'] === 0;
348353
}
349354
}

0 commit comments

Comments
 (0)