CronExpression::isDue()publicWC 1.0

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.

Method of the class: CronExpression{}

No Hooks.


true|false. Returns TRUE if the cron is due to run or FALSE if not


$CronExpression = new CronExpression();
$CronExpression->isDue( $currentTime );
(optional) Relative calculation date
Default: 'now'

CronExpression::isDue() code WC 8.6.1

public function isDue($currentTime = 'now')
    if ('now' === $currentTime) {
        $currentDate = date('Y-m-d H:i');
        $currentTime = strtotime($currentDate);
    } elseif ($currentTime instanceof DateTime) {
        $currentDate = $currentTime->format('Y-m-d H:i');
        $currentTime = strtotime($currentDate);
    } else {
        $currentTime = new DateTime($currentTime);
        $currentTime->setTime($currentTime->format('H'), $currentTime->format('i'), 0);
        $currentDate = $currentTime->format('Y-m-d H:i');
        $currentTime = (int)($currentTime->getTimestamp());

    return $this->getNextRunDate($currentDate, 0, true)->getTimestamp() == $currentTime;