From caa503025e04e3e9f23dc6c245e49f8ab1a894ee Mon Sep 17 00:00:00 2001 From: mscherer Date: Sun, 10 Aug 2025 13:58:23 +0200 Subject: [PATCH] Docs for toQuarterRange() split out from toQuarter() --- en/appendices/5-3-migration-guide.rst | 2 ++ en/core-libraries/time.rst | 14 ++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/en/appendices/5-3-migration-guide.rst b/en/appendices/5-3-migration-guide.rst index cfc1a64e5c..9ae2a720c1 100644 --- a/en/appendices/5-3-migration-guide.rst +++ b/en/appendices/5-3-migration-guide.rst @@ -88,6 +88,8 @@ I18n instances when iterating. - Added ``DatePeriod`` which wraps a php ``DatePeriod`` and returns ``Date`` instances when iterating. +- Added ``toQuarterRange()`` method to ``DateTime`` and ``FrozenTime`` classes which returns + an array containing the start and end dates of the quarter for the given date. Mailer ------ diff --git a/en/core-libraries/time.rst b/en/core-libraries/time.rst index 00ca458823..f8e4294e89 100644 --- a/en/core-libraries/time.rst +++ b/en/core-libraries/time.rst @@ -342,6 +342,7 @@ Conversion ========== .. php:method:: toQuarter() +.. php:method:: toQuarterRange() Once created, you can convert ``DateTime`` instances into timestamps or quarter values:: @@ -350,6 +351,19 @@ values:: echo $time->toQuarter(); // Outputs '1' echo $time->toUnixString(); // Outputs '1612069200' +.. versionadded:: 5.3.0 + The ``toQuarterRange()`` method was added. + +You can also get the date range for a quarter:: + + $time = new DateTime('2021-01-31'); + $range = $time->toQuarterRange(); + // Outputs ['2021-01-01', '2021-03-31'] + + $time = new DateTime('2021-12-25'); + $range = $time->toQuarterRange(); + // Outputs ['2021-10-01', '2021-12-31'] + Comparing With the Present ==========================