You are here

function system_get_date_formats in Drupal 7

Gets the list of defined date formats and attributes.

Parameters

$type: (optional) The date type name.

Return value

An associative array of date formats. The top-level keys are the names of the date types that the date formats belong to. The values are in turn associative arrays keyed by the format string, with the following keys:

  • dfid: The date format ID.
  • format: The format string.
  • type: The machine-readable name of the date type.
  • locales: An array of language codes. This can include both 2 character language codes like 'en and 'fr' and 5 character language codes like 'en-gb' and 'en-us'.
  • locked: A boolean indicating whether or not this date type should be configurable from the user interface.
  • module: The name of the module that defined this date format in its hook_date_formats(). An empty string if the format was user-defined.
  • is_new: A boolean indicating whether or not this date type is as of yet unsaved in the database.

If $type was defined, only the date formats associated with the given date type are returned, in a single associative array keyed by format string.

6 calls to system_get_date_formats()
locale_date_format_form in modules/locale/locale.admin.inc
Provide date localization configuration options to users.
system_add_date_formats_form_validate in modules/system/system.admin.inc
Validate new date format string submission.
system_add_date_format_type_form in modules/system/system.admin.inc
Add new date type.
system_date_formats_rebuild in modules/system/system.module
Resets the database cache of date formats and saves all new date formats.
system_date_time_formats in modules/system/system.admin.inc
Displays the date format strings overview page.

... See full list

4 string references to 'system_get_date_formats'
system_add_date_format_type_form in modules/system/system.admin.inc
Add new date type.
system_date_formats_rebuild in modules/system/system.module
Resets the database cache of date formats and saves all new date formats.
system_date_time_formats in modules/system/system.admin.inc
Displays the date format strings overview page.
system_date_time_settings in modules/system/system.admin.inc
Form builder; Configure the site date and time settings.

File

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

Code

function system_get_date_formats($type = NULL) {
  $date_formats =& drupal_static(__FUNCTION__);
  if (!isset($date_formats)) {
    $date_formats = _system_date_formats_build();
  }
  return $type ? isset($date_formats[$type]) ? $date_formats[$type] : FALSE : $date_formats;
}