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.

Метод класса: CronExpression{}

Хуков нет.

Возвращает

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

Использование

$CronExpression = new CronExpression();
$CronExpression->isDue( $currentTime );
$currentTime(строка|DateTime)
(optional) Relative calculation date
По умолчанию: 'now'

Код CronExpression::isDue() WC 8.7.0

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;
}