-
-
Notifications
You must be signed in to change notification settings - Fork 5.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Scheduler] Periodical triggers timing #20447
base: 6.4
Are you sure you want to change the base?
Conversation
d305960
to
f58f1eb
Compare
$until = '2023-06-12'; | ||
RecurringMessage::every('first Monday of next month', new Message(), from: $from, until: $until); | ||
|
||
If you don't pass a from parameter to your schedule, the first frequency period |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can merge this paragraph with the first one you added, as it's saying the same thing?
It's also possible to pass a from and until time for your schedule. For | ||
example, if you want to execute a command every day at 13:00:: | ||
|
||
$from = new \DateTimeImmutable('13:00', new \DateTimeZone('Europe/Paris')); | ||
RecurringMessage::every('1 day', new Message(), from: $from); | ||
|
||
Or if you want to execute a message every day until a specific date:: | ||
|
||
$until = '2023-06-12'; | ||
RecurringMessage::every('1 day', new Message(), until: $until); | ||
|
||
And you can even combine the from and until parameters for more granular | ||
control:: | ||
|
||
$from = new \DateTimeImmutable('2023-01-01 13:47', new \DateTimeZone('Europe/Paris')); | ||
$until = '2023-06-12'; | ||
RecurringMessage::every('first Monday of next month', new Message(), from: $from, until: $until); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We tend to favor "documentation in code examples" over normal text. So I would suggest merging this into one code block and adding a couple inline comments, like:
// execute a message every day at 13:00
$from = new \DateTimeImmutable('13:00', new \DateTimeZone('Europe/Paris'));
RecurringMessage::every('1 day', new Message(), from: $from);
// execute a message every day until a specific date
$until = '2023-06-12';
RecurringMessage::every('1 day', new Message(), until: $until);
// ... etc
Improves the explanation of periodical triggers in the Scheduler component.
Related to #20349