定制 fovxveym69/cron-expression 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

fovxveym69/cron-expression

最新稳定版本:v0.0.2

Composer 安装命令:

composer require fovxveym69/cron-expression

包简介

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

README 文档

README

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

Implementation

The reference documentation for this implementation is found at 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 ( * )

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 ( / )

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 ( , )

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 ( - )

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

Installing

Add the dependency to your project:

composer require han-xuefeng/cron-expression

Usage

example1

<?php

require_once '/vendor/autoload.php';

$cron = Cron\Cronexpr::parse('* * * * *');

echo $cron->next()->format('Y-m-d H:i:s');

example2

<?php

require_once '/vendor/autoload.php';

$cron = Cron\Cronexpr::parse('* * * * *');

// $cron->next()->format('Y-m-d H:i:s');

$cron->next('now','PRC')->format('Y-m-d H:i:s');

example3

<?php

require_once '/vendor/autoload.php';

// $cron = Cron\Cronexpr::parse('* * * * *');

$cron = Cron\Cronexpr::mustParse('* * * * *');

// $cron->next()->format('Y-m-d H:i:s');

// $cron->next('now','PRC')->format('Y-m-d H:i:s');

$cron->nextN('10');  //return array

Requirements

  • PHP 7.1+

统计信息

  • 总下载量: 7
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 2
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-08-31