Skip to content

Commit f58f1eb

Browse files
committed
[Scheduler] Periodical triggers timing
1 parent 119c3df commit f58f1eb

File tree

1 file changed

+27
-4
lines changed

1 file changed

+27
-4
lines changed

Diff for: scheduler.rst

+27-4
Original file line numberDiff line numberDiff line change
@@ -286,14 +286,37 @@ defined by PHP datetime functions::
286286
RecurringMessage::every('3 weeks', new Message());
287287
RecurringMessage::every('first Monday of next month', new Message());
288288

289-
$from = new \DateTimeImmutable('13:47', new \DateTimeZone('Europe/Paris'));
290-
$until = '2023-06-12';
291-
RecurringMessage::every('first Monday of next month', new Message(), $from, $until);
292-
293289
.. tip::
294290

295291
You can also define periodic tasks using :ref:`the AsPeriodicTask attribute <scheduler-attributes-periodic-task>`.
296292

293+
Be aware that the message isn't passed to the messenger when you start the
294+
scheduler. The message will only be executed after the first frequency period
295+
has passed.
296+
297+
It's also possible to pass a from and until time for your schedule. For
298+
example, if you want to execute a command every day at 13:00::
299+
300+
$from = new \DateTimeImmutable('13:00', new \DateTimeZone('Europe/Paris'));
301+
RecurringMessage::every('1 day', new Message(), from: $from);
302+
303+
Or if you want to execute a message every day until a specific date::
304+
305+
$until = '2023-06-12';
306+
RecurringMessage::every('1 day', new Message(), until: $until);
307+
308+
And you can even combine the from and until parameters for more granular
309+
control::
310+
311+
$from = new \DateTimeImmutable('2023-01-01 13:47', new \DateTimeZone('Europe/Paris'));
312+
$until = '2023-06-12';
313+
RecurringMessage::every('first Monday of next month', new Message(), from: $from, until: $until);
314+
315+
If you don't pass a from parameter to your schedule, the first frequency period
316+
is counted from the moment the scheduler is started. So if you start your
317+
scheduler at 8:33 and the message is scheduled to perform every hour, it
318+
will be executed at 9:33, 10:33, 11:33 and so on.
319+
297320
Custom Triggers
298321
~~~~~~~~~~~~~~~
299322

0 commit comments

Comments
 (0)