Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit d305960

Browse filesBrowse files
committed
[Scheduler] Periodical triggers timing
1 parent 119c3df commit d305960
Copy full SHA for d305960

File tree

Expand file treeCollapse file tree

1 file changed

+27
-4
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+27
-4
lines changed

‎scheduler.rst

Copy file name to clipboardExpand all lines: scheduler.rst
+27-4Lines changed: 27 additions & 4 deletions
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 scheduler when you start the
294+
messenger. 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('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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.