You are here

function date_seconds in Date 7

Same name and namespace in other branches
  1. 5.2 date_api.module \date_seconds()
  2. 6.2 date_api.module \date_seconds()
  3. 6 date_api.module \date_seconds()
  4. 7.3 date_api/date_api.module \date_seconds()
  5. 7.2 date_api/date_api.module \date_seconds()

An array of seconds.

Parameters

string $format:

$required: If not required, returned array will include a blank value.

Return value

array an array of seconds in the selected format.

2 calls to date_seconds()
date_is_all_day in date_api/date_api.module
Determine if a from/to date combination qualify as 'All day'.
date_parts_element in date_api/date_api_elements.inc
Create form elements for one or more date parts.

File

date_api/date_api.module, line 972
This module will make the date API available to other modules. Designed to provide a light but flexible assortment of functions and constants, with more functionality in additional files that are not loaded unless other modules specifically include them.

Code

function date_seconds($format = 's', $required = FALSE, $increment = 1) {
  $seconds = array();

  // Have to be sure $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;
}