Skip to content

Commit 754596b

Browse files
committed
[Scheduler] Periodical triggers timing
1 parent 979043e commit 754596b

File tree

1 file changed

+27
-4
lines changed

1 file changed

+27
-4
lines changed

scheduler.rst

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -272,14 +272,37 @@ defined by PHP datetime functions::
272272
RecurringMessage::every('3 weeks', new Message());
273273
RecurringMessage::every('first Monday of next month', new Message());
274274

275-
$from = new \DateTimeImmutable('13:47', new \DateTimeZone('Europe/Paris'));
276-
$until = '2023-06-12';
277-
RecurringMessage::every('first Monday of next month', new Message(), $from, $until);
278-
279275
.. tip::
280276

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

279+
Be aware that the message isn't passed to the scheduler when you start the
280+
messenger. The message will only be executed after the first frequency period
281+
has passed.
282+
283+
It's also possible to pass a from and until time for your schedule. For
284+
example, if you want to execute a command every day at 13:00::
285+
286+
$from = new \DateTimeImmutable('13:00', new \DateTimeZone('Europe/Paris'));
287+
RecurringMessage::every('1 day', new Message(), from: $from);
288+
289+
Or if you want to execute a message every day until a specific date::
290+
291+
$until = '2023-06-12';
292+
RecurringMessage::every('1 day', new Message(), until: $until);
293+
294+
And you can even combine the from and until parameters for more granular
295+
control::
296+
297+
$from = new \DateTimeImmutable('13:47', new \DateTimeZone('Europe/Paris'));
298+
$until = '2023-06-12';
299+
RecurringMessage::every('first Monday of next month', new Message(), from: $from, until: $until);
300+
301+
If you don't pass a from parameter to your schedule, the first frequency period
302+
is counted from the moment the scheduler is started. So if you start your
303+
scheduler at 8:33 and the message is scheduled to perform every hour, it
304+
will be executed at 9:33, 10:33, 11:33 and so on.
305+
283306
Custom Triggers
284307
~~~~~~~~~~~~~~~
285308

0 commit comments

Comments
 (0)