Skip to content

Commit

Permalink
Fix for Y-m-d date format.
Browse files Browse the repository at this point in the history
  • Loading branch information
oliver committed Jun 14, 2024
1 parent 947d2e4 commit 029cfb2
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/Traits/Deserializes.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,11 @@ protected static function deserializeValue(mixed $value, array|string $type): mi
if (! class_exists($type) && ! interface_exists($type)) {
throw new InvalidAttributeTypeException("Class `$type` does not exist");
} elseif ($type === DateTime::class || $type == \DateTimeInterface::class) {
return DateTime::createFromFormat(DateTime::RFC3339, $value);
if (strlen($value) === 10) {
return DateTime::createFromFormat('Y-m-d', $value);
} else {
return DateTime::createFromFormat(DateTime::RFC3339, $value);
}
}

$deserialized = $type::deserialize($value);
Expand Down

0 comments on commit 029cfb2

Please sign in to comment.