1 system.module | system_get_date_formats($date_format_name = NULL) |
Gets the list of defined date formats and attributes.
Parameters
$date_format_name: (optional) The date type name.
Return value
An associative array of date formats. The top-level keys are the: machine-readable names of the date formats. The values are associative arrays with the following keys:
- name: The string human readable name of the date format.
- pattern: The pattern string as usable by the PHP date() function.
If $date_format_name was defined, only the date formats associated with the given machine name are returned, in an associative array keyed by format string.
File
- core/
modules/ system/ system.module, line 4025 - Configuration system that lets administrators modify the workings of the site.
Code
function system_get_date_formats($date_format_name = NULL) {
$date_formats = &backdrop_static(__FUNCTION__, array());
if (empty($date_formats)) {
$date_formats = config_get('system.date', 'formats');
if (is_array($date_formats)) {
foreach ($date_formats as $name => $format) {
$date_formats[$name]['name'] = $name;
}
}
}
// Return either the specific format or all formats.
if (empty($date_format_name)) {
return $date_formats;
}
else {
return isset($date_formats[$date_format_name]) ? $date_formats[$date_format_name] : FALSE;
}
}