File tree Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -63,13 +63,27 @@ The Clock component also provides the ``now()`` function::
63
63
// Get the current time as a DateTimeImmutable instance
64
64
$now = now();
65
65
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
+
66
75
Later on this page you can learn how to use this clock in your services and tests.
67
76
68
77
.. versionadded :: 6.3
69
78
70
79
The :class: `Symfony\\ Component\\ Clock\\ Clock ` class and ``now() `` function
71
80
were introduced in Symfony 6.3.
72
81
82
+ .. versionadded :: 6.4
83
+
84
+ The ``modifier `` argument of the ``now() `` function was introduced in
85
+ Symfony 6.4.
86
+
73
87
Available Clocks Implementations
74
88
--------------------------------
75
89
@@ -252,3 +266,4 @@ control on your time-sensitive code's behavior.
252
266
The :class: `Symfony\\ Component\\ Clock\\ Test\\ ClockSensitiveTrait ` was introduced in Symfony 6.3.
253
267
254
268
.. _`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
You can’t perform that action at this time.
0 commit comments