function system_date_format_locale

7.x system.module system_date_format_locale($langcode = NULL, $type = NULL)

Gets the appropriate date format string for a date type and locale.

Parameters

$langcode: (optional) Language code for the current locale. This can be a 2 character language code like 'en' and 'fr' or a 5 character language code like 'en-gb' and 'en-us'.

$type: (optional) The date type name.

Return value

If $type and $langcode are specified, returns the corresponding date format string. If only $langcode is specified, returns an array of all date format strings for that locale, keyed by the date type. If neither is specified, or if no matching formats are found, returns FALSE.

3 calls to system_date_format_locale()
locale_date_format_form in drupal/modules/locale/locale.admin.inc
Provide date localization configuration options to users.
locale_get_localized_date_format in drupal/includes/locale.inc
Select locale date format details from database.
system_date_formats_rebuild in drupal/modules/system/system.module
Resets the database cache of date formats and saves all new date formats.
1 string reference to 'system_date_format_locale'
system_date_formats_rebuild in drupal/modules/system/system.module
Resets the database cache of date formats and saves all new date formats.

File

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

Code

function system_date_format_locale($langcode = NULL, $type = NULL) {
  $formats = &drupal_static(__FUNCTION__);

  if (empty($formats)) {
    $formats = array();
    $result = db_query("SELECT format, type, language FROM {date_format_locale}");
    foreach ($result as $record) {
      if (!isset($formats[$record->language])) {
        $formats[$record->language] = array();
      }
      $formats[$record->language][$record->type] = $record->format;
    }
  }

  if ($type && $langcode && !empty($formats[$langcode][$type])) {
    return $formats[$langcode][$type];
  }
  elseif ($langcode && !empty($formats[$langcode])) {
    return $formats[$langcode];
  }

  return FALSE;
}