Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions en/appendices/5-3-migration-guide.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
------
Expand Down
14 changes: 14 additions & 0 deletions en/core-libraries/time.rst
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,7 @@ Conversion
==========

.. php:method:: toQuarter()
.. php:method:: toQuarterRange()

Once created, you can convert ``DateTime`` instances into timestamps or quarter
values::
Expand All @@ -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
==========================

Expand Down
Loading