Skip to content

Commit

Permalink
Reintroduce zulu date formatting to HasArrayableAttributes
Browse files Browse the repository at this point in the history
  • Loading branch information
jlevers committed Jun 14, 2024
1 parent bfff702 commit c625e4e
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/Traits/HasArrayableAttributes.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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');
}
}

0 comments on commit c625e4e

Please sign in to comment.