PHP Cron Expression Parser ( LARAVEL )
The PHP cron expression parser can parse a CRON expression, determine if it is due to run, calculate the next run date of the expression, and calculate the previous run date of the expression. You can calculate dates far into the future or past by skipping n number of matching dates.
The parser can handle increments of ranges (e.g. */12, 2-59/3), intervals (e.g. 0-9), lists (e.g. 1,2,3), W to find the nearest weekday for a given day of the month, L to find the last day of the month, L to find the last given weekday of a month, and hash (#) to find the nth weekday of a given month.
More information about this fork can be found in the blog post here. tl;dr - v2.0.0 is a major breaking change, and @dragonmantank can better take care of the project in a separate fork.
Installing
Add the dependency to your project:
composer require dragonmantank/cron-expression
Usage
<?php require_once '/vendor/autoload.php'; // Works with predefined scheduling definitions
$cron = Cron\CronExpression::factory('@daily');
$cron->isDue();
echo $cron->getNextRunDate()->format('Y-m-d H:i:s');
echo $cron->getPreviousRunDate()->format('Y-m-d H:i:s'); // Works with complex expressions
$cron = Cron\CronExpression::factory('3-59/15 6-12 */15 1 2-5');
echo $cron->getNextRunDate()->format('Y-m-d H:i:s'); // Calculate a run date two iterations into the future
$cron = Cron\CronExpression::factory('@daily');
echo $cron->getNextRunDate(null, 2)->format('Y-m-d H:i:s'); // Calculate a run date relative to a specific time
$cron = Cron\CronExpression::factory('@monthly');
echo $cron->getNextRunDate('2010-01-12 00:00:00')->format('Y-m-d H:i:s');
CRON Expressions
A CRON expression is a string representing the schedule for a particular command to execute. The parts of a CRON schedule are as follows:
* * * * *
- - - - -
| | | | |
| | | | |
| | | | +----- day of week (0 - 7) (Sunday=0 or 7)
| | | +---------- month (1 - 12)
| | +--------------- day of month (1 - 31)
| +-------------------- hour (0 - 23)
+------------------------- min (0 - 59)
Requirements
- PHP 7.0+
- PHPUnit is required to run the unit tests
- Composer is required to run the unit tests
PHP Cron Expression Parser ( LARAVEL )的更多相关文章
- Quartz Cron 触发器 Cron Expression 的格式
转自:http://blog.csdn.net/yefengmeander/article/details/5985064 上一文中提到 Cron触发器可以接受一个表达式来指定执行JOB,下面看看这个 ...
- Cron Expression的用途
对于一些MIS系统,DeadLine,需要用户自己制定事件规则,Cron Expression应该可以派上用场. Cron Maker: http://www.cronmaker.com/
- About the Cron Expression
About the Cron Expression Cron is use in Linux for the time schedule Format Seconds Minutes Hours Da ...
- 【spring boot】使用定时任务@Scheduled 报错:Encountered invalid @Scheduled method 'dealShelf': Cron expression must consist of 6 fields (found 7 in "0 30 14 * * ? *")
在spring boot中使用使用定时任务@Scheduled 报错: org.springframework.beans.factory.BeanCreationException: Error c ...
- What is corresponding Cron expression to fire in every X seconds, where X > 60? --转载
原文地址:http://stackoverflow.com/questions/2996280/what-is-corresponding-cron-expression-to-fire-in-eve ...
- cron以及在laravel中使用cron
yum install vixie-cron yum install crontabs /bin/systemctl restart crond.service #启动服务 /bin/systemct ...
- [LeetCode] Ternary Expression Parser 三元表达式解析器
Given a string representing arbitrarily nested ternary expressions, calculate the result of the expr ...
- Ternary Expression Parser
Given a string representing arbitrarily nested ternary expressions, calculate the result of the expr ...
- Leetcode: Ternary Expression Parser
Given a string representing arbitrarily nested ternary expressions, calculate the result of the expr ...
随机推荐
- linux安装Anconda
1.下载 wget https://repo.anaconda.com/archive/Anaconda3-2018.12-Linux-x86_64.sh sh Anaconda3-2018.12-L ...
- df、du、fdisk
[df.du.fdisk] 参考:http://os.51cto.com/art/201012/240726.htm
- Manifest File
[Manifest File] on every build, webpack generates some webpack runtime code, which helps webpack do ...
- Linq to sql 之 ExecuteQuery 错误:指定的转换无效
问题:通过dbContext.ExecuteQuery 得到数据并赋值给一个集合. 代码: public IEnumerable<LeaveCodeSum> GetLeavTotal(st ...
- django1.10使用本地静态文件
django1.10使用本地静态文件方法 本文介绍的静态文件使用,是指启动web站点后,访问静态资源的用法,实际静态资源地址就是一个个的url 如果没有启动web站点,只是本地调试html页面,那直接 ...
- 健壮的网络编程IO函数-RIO包
RIO包 简介 Rio包即为Robust io函数包.包中函数是对Linux基本I/O函数的封装,使其更加健壮.高效,更适用于网络编程. 分析 Rio包由rio_t结构体和系列函数组成. 首先是两个不 ...
- android 区分wifi是5G还是2.4G(转)
http://bbs.csdn.net/topics/391033966?page=1 我一开始看这帖子,找不到答案,为了后来的人,我来回复吧.WifiManager wifiManager = (W ...
- CSS:opacity:0,visibility:hidden,display:none的区别
CSS中opacity=0,visibility=hidden,display=none的时候,三者有什么区别呢?? 参考了stackoverflow的博客,才发现区别如下所示: Here is a ...
- vue-webpack项目本地开发环境设置代理解决跨域问题
前言: 一般跨域问题只要后端配置好的话,是不需要前端做处理的,但也不能保证你遇到的所有后端都能很好的处理这个问题,这个时候可能就需要前端设置代理解决这个问题了. 配置方法: 1. config/ind ...
- 数据库(mysql)
一.left join right join inner join left join(左连接),在两张表进行连接查询时,会返回左表所有的行,即使在右表中没有匹配的记录. right join(右 ...