Skip to content

Commit a95c266

Browse files
committed
feature #19488 [Serializer] Document DateTimeNormalizer::CAST_KEY context option (SzymonKaminski)
This PR was merged into the 7.1 branch. Discussion ---------- [Serializer] Document `DateTimeNormalizer::CAST_KEY` context option PR documents new context option `CAST_KEY` of `DateTimeNormalizer` that allows to cast objects to integers or floats. Resolves #19485 Feature PR: symfony/symfony#53056 Commits ------- 5495c1d [Serializer] Document DateTimeNormalizer::CAST_KEY context option
2 parents 6e22157 + 5495c1d commit a95c266

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

components/serializer.rst

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -820,8 +820,14 @@ The Serializer component provides several built-in normalizers:
820820

821821
:class:`Symfony\\Component\\Serializer\\Normalizer\\DateTimeNormalizer`
822822
This normalizer converts :phpclass:`DateTimeInterface` objects (e.g.
823-
:phpclass:`DateTime` and :phpclass:`DateTimeImmutable`) into strings.
824-
By default, it uses the `RFC3339`_ format.
823+
:phpclass:`DateTime` and :phpclass:`DateTimeImmutable`) into strings,
824+
integers or floats. By default, it converts them to strings using the `RFC3339`_ format.
825+
To convert the objects to integers or floats, set the serializer context option
826+
``DateTimeNormalizer::CAST_KEY`` to ``int`` or ``float``.
827+
828+
.. versionadded:: 7.1
829+
830+
``DateTimeNormalizer::CAST_KEY`` context option was introduced in Symfony 7.1.
825831

826832
:class:`Symfony\\Component\\Serializer\\Normalizer\\DateTimeZoneNormalizer`
827833
This normalizer converts :phpclass:`DateTimeZone` objects into strings that

0 commit comments

Comments
 (0)