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.
$cronParts : array
$fieldFactory : \CronExpression_FieldFactory
$order : array
factory(string $expression, \CronExpression_FieldFactory $fieldFactory = null) : \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: @yearly, @annually) - Run once a year, midnight, Jan. 1 - 0 0 1 1 @monthly - Run once a month, midnight, first of month - 0 0 1 @weekly - Run once a week, midnight on Sun - 0 0 0 @daily - Run once a day, midnight - 0 0 @hourly - Run once an hour, first minute - 0 |
\CronExpression_FieldFactory | $fieldFactory | (optional) Field factory to use |
getNextRunDate(string|\DateTime $currentTime = 'now', int $nth, bool $allowCurrentDate = false) : \DateTime
Get a next run date relative to the current date or a specific date
string|\DateTime | $currentTime | (optional) Relative calculation date |
int | $nth | (optional) 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. |
bool | $allowCurrentDate | (optional) Set to TRUE to return the current date if it matches the cron expression |
on too many iterations
getPreviousRunDate(string|\DateTime $currentTime = 'now', int $nth, bool $allowCurrentDate = false) : \DateTime
Get a previous run date relative to the current date or a specific date
string|\DateTime | $currentTime | (optional) Relative calculation date |
int | $nth | (optional) Number of matches to skip before returning |
bool | $allowCurrentDate | (optional) Set to TRUE to return the current date if it matches the cron expression |
on too many iterations
getMultipleRunDates(int $total, string|\DateTime $currentTime = 'now', bool $invert = false, bool $allowCurrentDate = false) : array
Get multiple run dates starting at the current date or a specific date
int | $total | Set the total number of dates to calculate |
string|\DateTime | $currentTime | (optional) Relative calculation date |
bool | $invert | (optional) Set to TRUE to retrieve previous dates |
bool | $allowCurrentDate | (optional) 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 | (optional) 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') : bool
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 | (optional) Relative calculation date |
Returns TRUE if the cron is due to run or FALSE if not
getRunDate(string|\DateTime $currentTime = null, int $nth, bool $invert = false, bool $allowCurrentDate = false) : \DateTime
Get the next or previous run date of the expression relative to a date
string|\DateTime | $currentTime | (optional) Relative calculation date |
int | $nth | (optional) Number of matches to skip before returning |
bool | $invert | (optional) Set to TRUE to go backwards in time |
bool | $allowCurrentDate | (optional) Set to TRUE to return the current date if it matches the cron expression |
on too many iterations