From 5495c1d47846e784ad0f5e7066d39d4db1385798 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Szymon=20Kami=C5=84ski?= Date: Sat, 3 Feb 2024 14:59:16 +0100 Subject: [PATCH] [Serializer] Document DateTimeNormalizer::CAST_KEY context option --- components/serializer.rst | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/components/serializer.rst b/components/serializer.rst index dce30b8932b..0dbd223877d 100644 --- a/components/serializer.rst +++ b/components/serializer.rst @@ -820,8 +820,14 @@ The Serializer component provides several built-in normalizers: :class:`Symfony\\Component\\Serializer\\Normalizer\\DateTimeNormalizer` This normalizer converts :phpclass:`DateTimeInterface` objects (e.g. - :phpclass:`DateTime` and :phpclass:`DateTimeImmutable`) into strings. - By default, it uses the `RFC3339`_ format. + :phpclass:`DateTime` and :phpclass:`DateTimeImmutable`) into strings, + integers or floats. By default, it converts them to strings using the `RFC3339`_ format. + To convert the objects to integers or floats, set the serializer context option + ``DateTimeNormalizer::CAST_KEY`` to ``int`` or ``float``. + +.. versionadded:: 7.1 + + ``DateTimeNormalizer::CAST_KEY`` context option was introduced in Symfony 7.1. :class:`Symfony\\Component\\Serializer\\Normalizer\\DateTimeZoneNormalizer` This normalizer converts :phpclass:`DateTimeZone` objects into strings that