You are here

public function JobSchedulerCronTab::nextTime in Job Scheduler 8.3

Same name and namespace in other branches
  1. 8.2 src/JobSchedulerCronTab.php \Drupal\job_scheduler\JobSchedulerCronTab::nextTime()

Finds the next occurrence within the next year as unix timestamp.

Parameters

int $start_time: (optional) Starting time. Defaults to null.

int $limit: (optional) The time limit in days. Defaults to 366.

Return value

int|false The next occurrence as a unix timestamp, or false if there was an error.

Overrides JobSchedulerCronTabInterface::nextTime

File

src/JobSchedulerCronTab.php, line 79

Class

JobSchedulerCronTab
Class for job scheduler crontab.

Namespace

Drupal\job_scheduler

Code

public function nextTime($start_time = NULL, $limit = 366) {
  $start_time = isset($start_time) ? $start_time : time();

  // Get minutes, hours, mday, wday, mon, year.
  $start_date = getdate($start_time);
  if ($date = $this
    ->nextDate($start_date, $limit)) {
    return mktime($date['hours'], $date['minutes'], 0, $date['mon'], $date['mday'], $date['year']);
  }
  else {
    return 0;
  }
}