MINUTE
MINUTE = 0
CRON expression parser that can determine whether or not a CRON expression is due to run, the next run date and previous run date of a CRON expression.
The determinations made by this class are accurate if checked run once per minute (seconds are dropped from date time comparisons).
Schedule parts must map to: minute [0-59], hour [0-23], day of month, month [1-12|JAN-DEC], day of week [1-7|MON-SUN], and an optional year.
$fieldFactory : \Cron\FieldFactory
factory(string $expression, \Cron\FieldFactory $fieldFactory = null) : \Cron\CronExpression
Factory method to create a new CronExpression.
string | $expression | The CRON expression to create. There are several special predefined values which can be used to substitute the CRON expression:
|
\Cron\FieldFactory | $fieldFactory | Field factory to use |
__construct(string $expression, \Cron\FieldFactory $fieldFactory)
Parse a CRON expression
string | $expression | CRON expression (e.g. '8 ') |
\Cron\FieldFactory | $fieldFactory | Factory to create cron fields |
setExpression(string $value) : \Cron\CronExpression
Set or change the CRON expression
string | $value | CRON expression (e.g. 8 ) |
if not a valid CRON expression
setPart(integer $position, string $value) : \Cron\CronExpression
Set part of the CRON expression
integer | $position | The position of the CRON expression to set |
string | $value | The value to set |
if the value is not valid for the part
setMaxIterationCount(integer $maxIterationCount) : \Cron\CronExpression
Set max iteration count for searching next run dates
integer | $maxIterationCount | Max iteration count when searching for next run date |
getNextRunDate(string|\DateTime $currentTime = 'now', integer $nth, boolean $allowCurrentDate = false) : \DateTime
Get a next run date relative to the current date or a specific date
string|\DateTime | $currentTime | Relative calculation date |
integer | $nth | Number of matches to skip before returning a matching next run date. 0, the default, will return the current date and time if the next run date falls on the current date and time. Setting this value to 1 will skip the first match and go to the second match. Setting this value to 2 will skip the first 2 matches and so on. |
boolean | $allowCurrentDate | Set to TRUE to return the current date if it matches the cron expression. |
on too many iterations
getPreviousRunDate(string|\DateTime $currentTime = 'now', integer $nth, boolean $allowCurrentDate = false) : \DateTime
Get a previous run date relative to the current date or a specific date
string|\DateTime | $currentTime | Relative calculation date |
integer | $nth | Number of matches to skip before returning |
boolean | $allowCurrentDate | Set to TRUE to return the current date if it matches the cron expression |
on too many iterations
getMultipleRunDates(integer $total, string|\DateTime $currentTime = 'now', boolean $invert = false, boolean $allowCurrentDate = false) : array
Get multiple run dates starting at the current date or a specific date
integer | $total | Set the total number of dates to calculate |
string|\DateTime | $currentTime | Relative calculation date |
boolean | $invert | Set to TRUE to retrieve previous dates |
boolean | $allowCurrentDate | Set to TRUE to return the current date if it matches the cron expression |
Returns an array of run dates
getExpression(string $part = null) : string|null
Get all or part of the CRON expression
string | $part | Specify the part to retrieve or NULL to get the full cron schedule string. |
Returns the CRON expression, a part of the CRON expression, or NULL if the part was specified but not found
isDue(string|\DateTime $currentTime = 'now') : boolean
Determine if the cron is due to run based on the current date or a specific date. This method assumes that the current number of seconds are irrelevant, and should be called once per minute.
string|\DateTime | $currentTime | Relative calculation date |
Returns TRUE if the cron is due to run or FALSE if not
getRunDate(string|\DateTime $currentTime = null, integer $nth, boolean $invert = false, boolean $allowCurrentDate = false) : \DateTime
Get the next or previous run date of the expression relative to a date
string|\DateTime | $currentTime | Relative calculation date |
integer | $nth | Number of matches to skip before returning |
boolean | $invert | Set to TRUE to go backwards in time |
boolean | $allowCurrentDate | Set to TRUE to return the current date if it matches the cron expression |
on too many iterations