Disque\Queue\Queue::schedule PHP Method

schedule() public method

Pushes a job into the queue, setting it to be up for processing only at the specific date & time.
public schedule ( Disque\Queue\JobInterface $job, DateTime $when ) : Disque\Queue\JobInterface
$job Disque\Queue\JobInterface Job
$when DateTime Date & time on when job should be ready for processing
return Disque\Queue\JobInterface Job pushed
    public function schedule(JobInterface $job, DateTime $when)
    {
        if (!isset($this->timeZone)) {
            $this->timeZone = new DateTimeZone(self::DEFAULT_JOB_TIMEZONE);
        }
        $date = clone $when;
        $date->setTimeZone($this->timeZone);
        $now = new DateTime('now', $this->timeZone);
        if ($date < $now) {
            throw new InvalidArgumentException('Specified schedule time has passed');
        }
        return $this->push($job, ['delay' => $date->getTimestamp() - $now->getTimestamp()]);
    }