Download the PHP package crazynds/interval-expression without Composer
On this page you can find all versions of the php package crazynds/interval-expression. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download crazynds/interval-expression
More information about crazynds/interval-expression
Files in crazynds/interval-expression
Package interval-expression
Short Description Create complex interval for calendar
License MIT
Informations about the package interval-expression
Interval Expression for PHP
Interval system for schedules that represents recurrences that cannot be reached using cron.
Installation
-
Install the package
-
Check if expression is valid
- Iterate in generator
Expression Definition
[0-9]+ (daily|weekly|monthly|yearly) {rules}*
-
daily has no rules
-
weekly rules:
- {day of week [0-9]},{day of week [0-9]},...
- 0,3,5 => (Sunday, Wednesday and Friday)
- 1 => (Monday)
- * => (any 1 day of week)
-
monthly rules:
- {day of month [0-30]},{day of month [0-30]},...
- 12,15 => (day 12 and 15 of every month iteration)
- 10 => (day 10 of every month iteration)
- * => (any 1 day of month)
- yearly:
- {day of year [0-365]},{day of year [0-365]},...
- 12,15 => (day 12 and 15 of every year iteration)
- 1 => (first day of every year iteration)
- * => (any 1 day of year)
There can be multiple rules, every iteration will cycle through them. Ex: if there are two rules, the third iteration will use the first rule.
Examples
"2 weekly 1,5"
Description: Every 2 weeks on mondays and fridays
Inicial Date: 12-06-2022 14:30:00
Output:
- "13-06-2022 14:30:00" (monday)
- "17-06-2022 14:30:00" (friday)
- "27-06-2022 14:30:00" (monday)
- "01-07-2022 14:30:00" (friday)
"2 weekly 1 5"
Description: Every 2 weeks, the first occurence will be on a monday an the second will be on a friday.
Inicial Date: 12-06-2022 14:30:00
Output:
- "13-06-2022 14:30:00" (monday)
- "01-07-2022 14:30:00" (friday)
- "11-07-2022 14:30:00" (monday)
- "29-07-2022 14:30:00" (friday)
"2 weekly 1,5 5"
Description: Every 2 weeks, the first occurence will happen both on a monday and a friday, and the second will be only on a friday.
Inicial Date: 12-06-2022 14:30:00
Output:
- "13-06-2022 14:30:00" (monday)
- "17-06-2022 14:30:00" (friday)
- "01-07-2022 14:30:00" (friday)
- "11-07-2022 14:30:00" (monday)
"1 monthly 0,14 19"
Description: Every month, on first occurence will happen on the 1st and 15th day of the month, and the second will be only on a 20th day of the month.
Inicial Date: 12-06-2022 14:30:00
Output:
- "15-06-2022 14:30:00" (15th day)
- "20-07-2022 14:30:00" (20th day)
- "01-08-2022 14:30:00" (1st day)
- "15-08-2022 14:30:00" (15th day)
Tested and supported versions of PHP
- 8.X
- 7.X