diff --git a/src/JsonSchema/Constraints/FormatConstraint.php b/src/JsonSchema/Constraints/FormatConstraint.php index 39c3eb8f..482ba668 100644 --- a/src/JsonSchema/Constraints/FormatConstraint.php +++ b/src/JsonSchema/Constraints/FormatConstraint.php @@ -176,7 +176,7 @@ public function check(&$element, $schema = null, ?JsonPointer $path = null, $i = protected function validateDateTime($datetime, $format) { - $dt = \DateTime::createFromFormat($format, $datetime); + $dt = \DateTime::createFromFormat($format, (string) $datetime); if (!$dt) { return false; diff --git a/tests/Constraints/FormatTest.php b/tests/Constraints/FormatTest.php index 98c0299e..2d91e5fe 100644 --- a/tests/Constraints/FormatTest.php +++ b/tests/Constraints/FormatTest.php @@ -186,7 +186,7 @@ public function getInvalidFormats(): array ['1999-01-11T00:00:00+1:00', 'date-time'], ['1999.000Z-01-11T00:00:00+1:00', 'date-time'], - [(string) PHP_INT_MAX, 'utc-millisec'], + [PHP_INT_MAX, 'utc-millisec'], ['grey', 'color'], ['#HHH', 'color'],