tomk / cronparser
解析 CRON 格式,检查时间匹配,或获取下一个/上一个匹配项
dev-master
2014-09-04 08:15 UTC
Requires (Dev)
This package is auto-updated.
Last update: 2024-09-19 09:24:08 UTC
README
PHP 类,用于解析 CRON 格式、检查时间匹配或确定下一个和上一个匹配时间。
安装
将此包添加到 composer.json 的 required 部分
"required": {
"tomk/cronparser":"*"
}
用法
以下为可用的公共方法。
// Returns true if pattern is valid format, false otherwise CronParser::isValid(string $pattern); // Returns true if the time matches the pattern supplied. CronParser::isDue(string $pattern [, $time = time()]); // Returns a DateTime object of the next matching time from $time. // If $now is true, will accept $time as a match. Otherwise finds the next match in the future. CronParser::nextRun(string $pattern [, $time = time() [, $now = false]]); // Returns a DateTime object of the previous matching time from $time. // If $now is true, will accept $time as a match. Otherwise finds the next match in the past. CronParser::prevRun(string $pattern [, $time = time() [, $now = false]]);
CRON 表达式
请参考维基百科上的 CRON 格式:[http://en.wikipedia.org/wiki/Cron#CRON_expression]