From c625e4e86695f18ad581890d7297d9b1a9b9129a Mon Sep 17 00:00:00 2001 From: Jesse Evers Date: Fri, 14 Jun 2024 11:19:01 -0400 Subject: [PATCH] Reintroduce zulu date formatting to HasArrayableAttributes --- src/Traits/HasArrayableAttributes.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Traits/HasArrayableAttributes.php b/src/Traits/HasArrayableAttributes.php index 2bcb7879..aebc65b5 100644 --- a/src/Traits/HasArrayableAttributes.php +++ b/src/Traits/HasArrayableAttributes.php @@ -61,7 +61,7 @@ public function valueToArray(mixed $value, array|string $type): mixed if (is_null($value)) { return null; } elseif ($value instanceof DateTimeInterface) { - return $value->format(DateTime::RFC3339); + return $this->toZuluString($value); } elseif (is_string($type)) { if (class_exists($type)) { return $value->toArray(); @@ -87,4 +87,9 @@ public function valueToArray(mixed $value, array|string $type): mixed throw new InvalidAttributeTypeException("Unrecognized attribute type `$type`"); } + + private function toZuluString(DateTimeInterface $dateTime) + { + return $dateTime->format('Y-m-d\TH:i:s\Z'); + } }