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 );
(optional) Relative calculation date
По умолчанию: 'now'

Код CronExpression::isDue() WC 6.9.4

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;