function system_get_date_formats

Gets the list of defined date formats and attributes.

Parameters

$date_format_id: (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: An associative array of patterns that will modify the format of the date, keyed with 'php' for normal PHP date pattern and 'intl' for the alternate pattern used by the IntlDateFormatter.

If $date_format_id was defined, only the date formats associated with the given machine name are returned, in an associative array keyed by format string.

10 calls to system_get_date_formats()
Date::buildOptionsForm in drupal/core/modules/views/lib/Drupal/views/Plugin/views/field/Date.php
Default options form that provides the label widget that all fields should have.
system_configure_date_formats_form in drupal/core/modules/system/system.admin.inc
Allow users to add additional date formats.
system_date_delete_format_form in drupal/core/modules/system/system.admin.inc
Menu callback; present a form for deleting a date format.
system_date_delete_format_form_submit in drupal/core/modules/system/system.admin.inc
Delete a configured date format.
system_date_formats_form_validate in drupal/core/modules/system/system.admin.inc
Validate date format string submission.

... See full list

File

drupal/core/modules/system/system.module, line 3678
Configuration system that lets administrators modify the workings of the site.

Code

function system_get_date_formats($date_format_id = NULL) {
  $date_formats = config('system.date')
    ->get('formats');

  // Return either the specific format or all formats.
  return empty($date_format_id) ? $date_formats : $date_formats[$date_format_id];
}