1 date.inc date_seconds($format = 's', $required = FALSE, $increment = 1)

Constructs an array of seconds.

Parameters

string $format: A date format string.

bool $required: (optional) If FALSE, the returned array will include a blank value. Defaults to FALSE.

int $increment: (optional) The number by which the seconds should be incremented. Defaults to 1.

Return value

array: An array of seconds in the selected format.

File

core/includes/date.inc, line 370
Date API functions.

Code

function date_seconds($format = 's', $required = FALSE, $increment = 1) {
  $seconds = array();
  // Ensure $increment has a value so we don't loop endlessly.
  if (empty($increment)) {
    $increment = 1;
  }
  for ($i = 0; $i < 60; $i += $increment) {
    $seconds[$i] = $i < 10 && $format == 's' ? "0$i" : $i;
  }
  $none = array('' => '');
  return !$required ? $none + $seconds : $seconds;
}