PHPackages                             fovxveym69/cron-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. fovxveym69/cron-expression

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

fovxveym69/cron-expression
==========================

Calculate the next run date a CRON expression. Support years and seconds (计算crontab表达式下一个执行日期，支持年和秒)

v0.0.2(2y ago)07MITPHP

Since Aug 31Pushed 2y agoCompare

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

READMEChangelog (2)DependenciesVersions (3)Used By (0)

cron-expression
===============

[](#cron-expression)

Calculate the next run date a CRON expression. Support years and seconds (计算crontab表达式下一个执行日期，支持年和秒)

Implementation
==============

[](#implementation)

The reference documentation for this implementation is found at [https://en.wikipedia.org/wiki/Cron#CRON\_expression](https://en.wikipedia.org/wiki/Cron#CRON_expression), which I copy/pasted here (laziness!) with modifications where this implementation differs:

```
Field name     Mandatory?   Allowed values    Allowed special characters
----------     ----------   --------------    --------------------------
Seconds        No           0-59              * / , -
Minutes        Yes          0-59              * / , -
Hours          Yes          0-23              * / , -
Day of month   Yes          1-31              * / , -
Month          Yes          1-12              * / , -
Day of week    Yes          0-6               * / , -
Year           No           1970–2099         * / , -

```

#### Asterisk ( \* )

[](#asterisk---)

The asterisk indicates that the cron expression matches for all values of the field. E.g., using an asterisk in the 4th field (month) indicates every month.

#### Slash ( / )

[](#slash---)

Slashes describe increments of ranges. For example `3-59/15` in the minute field indicate the third minute of the hour and every 15 minutes thereafter. The form `*/...` is equivalent to the form "first-last/...", that is, an increment over the largest possible range of the field.

#### Comma ( , )

[](#comma---)

Commas are used to separate items of a list. For example 3,4,5 in the day filed indicate the day of The 3rd, 4th and 5th of every month.

#### Hyphen ( - )

[](#hyphen----)

Hyphens define ranges. For example, 2000-2010 indicates every year between 2000 and 2010 AD, inclusive.

Installing
==========

[](#installing)

Add the dependency to your project:

```
composer require han-xuefeng/cron-expression
```

Usage
=====

[](#usage)

#### example1

[](#example1)

```
