Skip to content

Commit 4d66627

Browse files
committed
feature symfony#18771 [Clock] Add $modifier argument to the now() helper (alexandre-daubois)
This PR was merged into the 6.4 branch. Discussion ---------- [Clock] Add $modifier argument to the `now()` helper Fix symfony#18770 Commits ------- 30a2eed [Clock] Add $modifier argument to the `now()` helper
2 parents 61d7898 + 30a2eed commit 4d66627

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

components/clock.rst

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,13 +63,27 @@ The Clock component also provides the ``now()`` function::
6363
// Get the current time as a DateTimeImmutable instance
6464
$now = now();
6565

66+
The ``now()`` function takes an optional ``modifier`` argument
67+
which will be applied to the current time::
68+
69+
$later = now('+3 hours');
70+
71+
$yesterday = now('-1 day');
72+
73+
You can use any string `accepted by the DateTime constructor`_.
74+
6675
Later on this page you can learn how to use this clock in your services and tests.
6776

6877
.. versionadded:: 6.3
6978

7079
The :class:`Symfony\\Component\\Clock\\Clock` class and ``now()`` function
7180
were introduced in Symfony 6.3.
7281

82+
.. versionadded:: 6.4
83+
84+
The ``modifier`` argument of the ``now()`` function was introduced in
85+
Symfony 6.4.
86+
7387
Available Clocks Implementations
7488
--------------------------------
7589

@@ -252,3 +266,4 @@ control on your time-sensitive code's behavior.
252266
The :class:`Symfony\\Component\\Clock\\Test\\ClockSensitiveTrait` was introduced in Symfony 6.3.
253267

254268
.. _`PSR-20`: https://www.php-fig.org/psr/psr-20/
269+
.. _`accepted by the DateTime constructor`: https://www.php.net/manual/en/datetime.formats.php

0 commit comments

Comments
 (0)