PHPackages                             adhocore/cron-expr - 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. adhocore/cron-expr

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

adhocore/cron-expr
==================

Ultra lightweight Cron Expression parser for PHP

1.1.3(4y ago)53436.1k↓23.9%5[2 issues](https://github.com/adhocore/php-cron-expr/issues)[1 PRs](https://github.com/adhocore/php-cron-expr/pulls)3MITPHPPHP &gt;=7.0CI failing

Since Jun 13Pushed 1y ago2 watchersCompare

[ Source](https://github.com/adhocore/php-cron-expr)[ Packagist](https://packagist.org/packages/adhocore/cron-expr)[ Fund](https://paypal.me/ji10)[ RSS](/packages/adhocore-cron-expr/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (10)Dependencies (1)Versions (15)Used By (3)

adhocore/cron-expr
------------------

[](#adhocorecron-expr)

[![Latest Version](https://camo.githubusercontent.com/aa6b296604547a269636bbb8c835fa2e8120dc8bc64f2da08d98e91f782f3394/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652f6164686f636f72652f7068702d63726f6e2d657870722e7376673f7374796c653d666c61742d737175617265)](https://github.com/adhocore/php-cron-expr/releases)[![Travis Build](https://camo.githubusercontent.com/ee91ac8ae249415df8a25d6f2820d973f953ee6847b44289138433a07c5cef01/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f6164686f636f72652f7068702d63726f6e2d657870722f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/adhocore/php-cron-expr?branch=master)[![Scrutinizer CI](https://camo.githubusercontent.com/2150ac436b80445f001c82c085feed15c6045533a5f74cc3e2306ec6bfed97a7/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f6164686f636f72652f7068702d63726f6e2d657870722e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/adhocore/php-cron-expr/?branch=master)[![Codecov branch](https://camo.githubusercontent.com/0b5d91c1ece87839cff66abd5ccf95c10afba0c0a4620362df5e60ae3083b54f/68747470733a2f2f696d672e736869656c64732e696f2f636f6465636f762f632f6769746875622f6164686f636f72652f7068702d63726f6e2d657870722f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://codecov.io/gh/adhocore/php-cron-expr)[![StyleCI](https://camo.githubusercontent.com/e49df9cd2c17592cfa3b03b46a4cd6daba4eff9253d67b5a5ec42c4618932c13/68747470733a2f2f7374796c6563692e696f2f7265706f732f39343232383336332f736869656c64)](https://styleci.io/repos/94228363)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE)[![Tweet](https://camo.githubusercontent.com/cb820a0ecc9645168e33b03925d7f14691262ddbaeaf66a0a91697803d0cba2d/68747470733a2f2f696d672e736869656c64732e696f2f747769747465722f75726c2f687474702f736869656c64732e696f2e7376673f7374796c653d736f6369616c)](https://twitter.com/intent/tweet?text=Lightweight+and+fast+cron+expression+parser+for+PHP&url=https://github.com/adhocore/php-cron-expr&hashtags=php,cron,cronparser,parser,cronexpr)[![Support](https://camo.githubusercontent.com/6687993dc9b60228356720a501b7c197c8c9a82194cac1b1c72d0dea95e6ad32/68747470733a2f2f696d672e736869656c64732e696f2f7374617469632f76313f6c6162656c3d537570706f7274266d6573736167653d254532253944254134266c6f676f3d476974487562)](https://github.com/sponsors/adhocore)

- Lightweight Cron expression parser library for PHP.
- Zero dependency.
- Very **fast** because it bails early in case a segment doesnt match.
- Real [benchmark](https://github.com/adhocore/php-cron-bench) shows it is about 7.54x to 12.92x faster than `dragonmantank/cron-expression`

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

[](#installation)

```
composer require adhocore/cron-expr

# PHP5.6 or lower
composer require adhocore/cron-expr:0.1.0
```

Usage
-----

[](#usage)

**Basic**

```
use Ahc\Cron\Expression;
use Ahc\Cron\Normalizer;

Expression::isDue('@always');
Expression::isDue(Normalizer::HOURLY, '2015-01-01 00:00:00');
Expression::isDue('*/20 * * * *', new DateTime);
Expression::isDue('5-34/4 * * * *', time());

// Dont like static calls? Below is possible too!
$expr = new Expression;
$expr->isCronDue('*/1 * * * *', time());
```

**Bulk checks**

When checking for several jobs at once, if more than one of the jobs share equivalent expression then the evaluation is done only once per go thus greatly improving performnce.

```
use Ahc\Cron\Expression;

$jobs = [
    'job1' => '*/2 */2 * * *',
    'job1' => '* 20,21,22 * * *',
    'job3' => '7-9 * */9 * *',
    'job4' => '*/5 * * * *',
    'job5' => '@5minutes',     // equivalent to job4 (so it is due if job4 is due)
    'job6' => '7-9 * */9 * *', // exact same as job3 (so it is due if job3 is due)
];

// The second param $time can be used same as above: null/time()/date string/DateTime
$dues = Expression::getDues($jobs, '2015-08-10 21:50:00');
// ['job1', 'job4', 'job5']

// Dont like static calls? Below is possible too!
$expr = new Expression;
$dues = $expr->filter($jobs, time());
```

### Cron Expression

[](#cron-expression)

Cron expression normally consists of 5 segments viz:

```

```

and sometimes there can be 6th segment for `` at the end.

### Real Abbreviations

[](#real-abbreviations)

You can use real abbreviations for month and week days. eg: `JAN`, `dec`, `fri`, `SUN`

### Tags

[](#tags)

Following tags are available and they are converted to real cron expressions before parsing:

- *@yearly* or *@annually* - every year
- *@monthly* - every month
- *@daily* - every day
- *@weekly* - every week
- *@hourly* - every hour
- *@5minutes* - every 5 minutes
- *@10minutes* - every 10 minutes
- *@15minutes* - every 15 minutes
- *@30minutes* - every 30 minutes
- *@always* - every minute

> You can refer them with constants from `Ahc\Cron\Normalizer` like `Ahc\Cron\Normalizer::WEEKLY`

### Modifiers

[](#modifiers)

Following modifiers supported

- *Day of Month / 3rd segment:*
    - `L` stands for last day of month (eg: `L` could mean 29th for February in leap year)
    - `W` stands for closest week day (eg: `10W` is closest week days (MON-FRI) to 10th date)
- *Day of Week / 5th segment:*
    - `L` stands for last weekday of month (eg: `2L` is last monday)
    - `#` stands for nth day of week in the month (eg: `1#2` is second sunday)

LICENSE
-------

[](#license)

> © [MIT](./LICENSE) | 2017-2019, Jitendra Adhikari

Credits
-------

[](#credits)

This project is release managed by [please](https://github.com/adhocore/please).

###  Health Score

44

—

FairBetter than 92% of packages

Maintenance26

Infrequent updates — may be unmaintained

Popularity48

Moderate usage in the ecosystem

Community19

Small or concentrated contributor base

Maturity66

Established project with proven stability

 Bus Factor1

Top contributor holds 98.3% 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 ~132 days

Recently: every ~167 days

Total

13

Last Release

1672d ago

Major Versions

v0.1.0 → 1.0.02019-12-22

PHP version history (2 changes)v0.0.4PHP &gt;=5.4

1.1.0PHP &gt;=7.0

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/2908547?v=4)[Jitendra Adhikari](/maintainers/adhocore)[@adhocore](https://github.com/adhocore)

---

Top Contributors

[![adhocore](https://avatars.githubusercontent.com/u/2908547?v=4)](https://github.com/adhocore "adhocore (113 commits)")[![peter279k](https://avatars.githubusercontent.com/u/9021747?v=4)](https://github.com/peter279k "peter279k (1 commits)")[![StyleCIBot](https://avatars.githubusercontent.com/u/11048387?v=4)](https://github.com/StyleCIBot "StyleCIBot (1 commits)")

---

Tags

adhocorecroncron-exprcron-expressioncron-parsercron-relaycrontabcrontab-parserphp-cronphp-crontabschedulercroncron-expressioncron-parsercron-expr

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/adhocore-cron-expr/health.svg)

```
[![Health](https://phpackages.com/badges/adhocore-cron-expr/health.svg)](https://phpackages.com/packages/adhocore-cron-expr)
```

###  Alternatives

[dragonmantank/cron-expression

CRON for PHP: Calculate the next or previous run date and determine if a CRON expression is due

4.7k474.1M487](/packages/dragonmantank-cron-expression)[lorisleiva/cron-translator

Makes CRON expressions human-readable

3148.5M31](/packages/lorisleiva-cron-translator)[symfony/scheduler

Provides scheduling through Symfony Messenger

8910.8M52](/packages/symfony-scheduler)[mybuilder/cronos

Configure Cron task through PHP

152526.8k2](/packages/mybuilder-cronos)[mult1mate/cron-manager

Flexible cron tasks manager for MVC-type applications

40338.5k3](/packages/mult1mate-cron-manager)[butschster/cron-expression-generator

Cron expression generator

511.4M2](/packages/butschster-cron-expression-generator)

PHPackages © 2026

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