function system_date_format_locale
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.
File
- modules/system/system.module, line 3681
- 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; }
© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/modules!system!system.module/function/system_date_format_locale/7.x