public function isDue($currentTime = 'now', $timeZone = null)
    {
        if (is_null($timeZone)) {
            $timeZone = date_default_timezone_get();
        }
        
        if ('now' === $currentTime) {
            $currentDate = date('Y-m-d H:i');
            $currentTime = strtotime($currentDate);
        } elseif ($currentTime instanceof DateTime) {
            $currentDate = clone $currentTime;
            // Ensure time in 'current' timezone is used
            $currentDate->setTimezone(new DateTimeZone($timeZone));
            $currentDate = $currentDate->format('Y-m-d H:i');
            $currentTime = strtotime($currentDate);
        } elseif ($currentTime instanceof DateTimeImmutable) {
            $currentDate = DateTime::createFromFormat('U', $currentTime->format('U'));
            $currentDate->setTimezone(new DateTimeZone($timeZone));
            $currentDate = $currentDate->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 = $currentTime->getTimeStamp();
        }

        try {
            return $this->getNextRunDate($currentDate, 0, true)->getTimestamp() == $currentTime;
        } catch (Exception $e) {
            return false;
        }
    }
public function isDue($currentTime = 'now', $timeZone = null)
    {
        if (is_null($timeZone)) {
            $timeZone = date_default_timezone_get();
        }
        
        if ('now' === $currentTime) {
            $currentDate = date('Y-m-d H:i');
            $currentTime = strtotime($currentDate);
        } elseif ($currentTime instanceof DateTime) {
            $currentDate = clone $currentTime;
            // Ensure time in 'current' timezone is used
            $currentDate->setTimezone(new DateTimeZone($timeZone));
            $currentDate = $currentDate->format('Y-m-d H:i');
            $currentTime = strtotime($currentDate);
        } elseif ($currentTime instanceof DateTimeImmutable) {
            $currentDate = DateTime::createFromFormat('U', $currentTime->format('U'));
            $currentDate->setTimezone(new DateTimeZone($timeZone));
            $currentDate = $currentDate->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 = $currentTime->getTimeStamp();
        }

        try {
            return $this->getNextRunDate($currentDate, 0, true)->getTimestamp() == $currentTime;
        } catch (Exception $e) {
            return false;
        }
    }
public function isDue ( $ currentTime = 'now' , $ timeZone = null ) { if ( is_null ( $ timeZone ) ) { $ timeZone = date_default_timezone_get ( ) ; } if ( 'now' === $ currentTime ) { $ currentDate = date ( 'Y-m-d H:i' ) ; $ currentTime = strtotime ( $ currentDate ) ; } elseif ( $ currentTime instanceof DateTime ) { $ currentDate = clone $ currentTime ; // Ensure time in 'current' timezone is used $ currentDate -> setTimezone ( new DateTimeZone ( $ timeZone ) ) ; $ currentDate = $ currentDate -> format ( 'Y-m-d H:i' ) ; $ currentTime = strtotime ( $ currentDate ) ; } elseif ( $ currentTime instanceof DateTimeImmutable ) { $ currentDate = DateTime :: createFromFormat ( 'U' , $ currentTime -> format ( 'U' ) ) ; $ currentDate -> setTimezone ( new DateTimeZone ( $ timeZone ) ) ; $ currentDate = $ currentDate -> 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 = $ currentTime -> getTimeStamp ( ) ; } try { return $ this -> getNextRunDate ( $ currentDate , 0 , true ) -> getTimestamp ( ) == $ currentTime ; } catch ( Exception $ e ) { return false ; } }
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.

@param string|\DateTime $currentTime Relative calculation date
@param null|string      $timeZone    Timezone to use instead of the system default

@return bool Returns TRUE if the cron is due to run or FALSE if not
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 .