function date_seconds in Date 7.2
Same name and namespace in other branches
- 5.2 date_api.module \date_seconds()
- 6.2 date_api.module \date_seconds()
- 6 date_api.module \date_seconds()
- 7.3 date_api/date_api.module \date_seconds()
- 7 date_api/date_api.module \date_seconds()
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.
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 start/end date combination qualify as 'All day'.
- date_parts_element in date_api/
date_api_elements.inc - Creates form elements for one or more date parts.
File
- date_api/
date_api.module, line 1472 - This module will make the date API available to other modules.
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;
}