PHPackages                             crazynds/interval-expression - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. crazynds/interval-expression

AbandonedArchivedLibrary[Utility &amp; Helpers](/categories/utility)

crazynds/interval-expression
============================

Create complex interval for calendar

v1.1.0(1y ago)0957MITPHPPHP &gt;=7.0

Since Jun 12Pushed 1y ago1 watchersCompare

[ Source](https://github.com/crazynds/IntervalExpression)[ Packagist](https://packagist.org/packages/crazynds/interval-expression)[ RSS](/packages/crazynds-interval-expression/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (6)Dependencies (1)Versions (7)Used By (0)

Interval Expression for PHP
===========================

[](#interval-expression-for-php)

[![Latest Stable Version](https://camo.githubusercontent.com/246bd3474d89f0aec2f989b932b8312411a2df281d318de8200edf069c9845b3/687474703a2f2f706f7365722e707567782e6f72672f6372617a796e64732f696e74657276616c2d65787072657373696f6e2f76)](https://packagist.org/packages/crazynds/interval-expression)[![Total Downloads](https://camo.githubusercontent.com/dea37414a5b95788b7d2c5c20082627b2eafe104048712cf9a959c366338ae5b/687474703a2f2f706f7365722e707567782e6f72672f6372617a796e64732f696e74657276616c2d65787072657373696f6e2f646f776e6c6f616473)](https://packagist.org/packages/crazynds/interval-expression)[![License](https://camo.githubusercontent.com/7121c9848dce8234e181d4ffd245e16a4ea43c0aacb6551b3a4653df39e878eb/687474703a2f2f706f7365722e707567782e6f72672f6372617a796e64732f696e74657276616c2d65787072657373696f6e2f6c6963656e7365)](https://packagist.org/packages/crazynds/interval-expression)

Interval system for schedules that represents recurrences that cannot be reached using cron.

Installation
------------

[](#installation)

1. Install the package

```
composer require crazynds/interval-expression
```

2. Check if expression is valid

```
use Crazynds\IntervalExpression\Interval;

$interval = new Interval();
// Expression for every 1 week on monday, wednesday and friday
$expression = '1 weekly 1,3,5';

if($interval->validate($expression)){
    //is valid expression
    $interval->parse($expression);

}

if($interval->parse($expression)){
    //this way check if the expression is valid too and apply the expression in the interval
}
```

3. Iterate in generator

```
use Carbon\Carbon;
use Crazynds\IntervalExpression\Interval;

$dateStart = Carbon::parse('12-06-2022 14:30:00');
$dateEnd = Carbon::parse('01-08-2030 18:30:00');

$interval = new Interval();
// Expression for every 1 week on monday, wednesday and friday
$expression = '1 weekly 1,3,5';

$dates = [];
if($interval->parse($expression)){
    $generator = $interval->generator($dateStart,$dateEnd);

    $started = $generator->current()->format('d-m-Y H:i:s');
    while($generator->hasNext()){
        $dates[] = $generator->next()->format('d-m-Y H:i:s');
    }
}
var_dump($dates);
```

Expression Definition
---------------------

[](#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 =&gt; (Sunday, Wednesday and Friday)
    - 1 =&gt; (Monday)
    - \* =&gt; (any 1 day of week)
- monthly rules:

    - {day of month \[0-30\]},{day of month \[0-30\]},...
    - 12,15 =&gt; (day 12 and 15 of every month iteration)
    - 10 =&gt; (day 10 of every month iteration)
    - \* =&gt; (any 1 day of month)
- yearly:

    - {day of year \[0-365\]},{day of year \[0-365\]},...
    - 12,15 =&gt; (day 12 and 15 of every year iteration)
    - 1 =&gt; (first day of every year iteration)
    - \* =&gt; (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
--------

[](#examples)

#### "2 weekly 1,5"

[](#2-weekly-15)

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"

[](#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"

[](#2-weekly-15-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"

[](#1-monthly-014-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
------------------------------------

[](#tested-and-supported-versions-of-php)

- 8.X
- 7.X

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance44

Moderate activity, may be stable

Popularity14

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity47

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~198 days

Recently: every ~248 days

Total

6

Last Release

443d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/812e99abe6732b42bcbcbc4eb58f23d432070f5d219c497ad42af5f65719e0ac?d=identicon)[crazynds](/maintainers/crazynds)

---

Top Contributors

[![crazynds](https://avatars.githubusercontent.com/u/36674096?v=4)](https://github.com/crazynds "crazynds (22 commits)")

### Embed Badge

![Health badge](/badges/crazynds-interval-expression/health.svg)

```
[![Health](https://phpackages.com/badges/crazynds-interval-expression/health.svg)](https://phpackages.com/packages/crazynds-interval-expression)
```

###  Alternatives

[ashallendesign/short-url

A Laravel package for creating shortened URLs for your web apps.

1.4k1.9M4](/packages/ashallendesign-short-url)[solspace/craft-freeform

The most flexible and user-friendly form building plugin!

52664.9k12](/packages/solspace-craft-freeform)[intervention/zodiac

Zodiac Sign Calculator

58191.7k](/packages/intervention-zodiac)[erlandmuchasaj/laravel-gzip

Gzip your responses.

40129.3k2](/packages/erlandmuchasaj-laravel-gzip)[solspace/craft-calendar

The most powerful event management and calendaring plugin!

1830.8k1](/packages/solspace-craft-calendar)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
