function system_date_format_locale

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

Parameters

$langcode: (optional) String 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'.

$date_format_id: (optional) String machine name for the date format.

Return value

If $date_format_id 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 returns FALSE.

1 call to system_date_format_locale()
system_date_format_localize_form in drupal/core/modules/system/system.admin.inc
Form constructor for the date localization configuration form.

File

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

Code

function system_date_format_locale($langcode = NULL, $date_format_id = NULL) {
  $formats =& drupal_static(__FUNCTION__);
  if (!isset($formats[$langcode])) {
    $formats[$langcode] = config('locale.config.' . $langcode . '.system.date')
      ->get('formats');
  }
  if ($date_format_id && $langcode && !empty($formats[$langcode][$date_format_id])) {
    return $formats[$langcode][$date_format_id];
  }
  elseif ($langcode && !empty($formats[$langcode])) {
    return $formats[$langcode];
  }
  return FALSE;
}