date_format_locale

Versions
5 – 6
date_format_locale($langcode = NULL, $type = NULL, $reset = FALSE)

Get the appropriate date format for a type and locale.

Parameters

$langcode Language code for the current locale. This can be a 2 character language code like 'en', 'fr', or a longer 5 character code like 'en-gb'.

$type Date format type: short, medium, long, custom.

$reset Whether or not to reset this function's internal cache (defaults to FALSE).

Return value

The format string, or NULL if no matching format found.

▾ 3 functions call date_format_locale()

date_formats_rebuild in contributions/date/date_api.module
Resets the database cache of date formats, and saves all new date formats to the database.
date_locale_format_form in contributions/date/date_locale/date_locale.module
Display list of enabled languages to configure date formats for.
date_locale_get_locale_date_format in contributions/date/date_locale/date_locale.module
Select locale date format details from database.

Code

contributions/date/date_api.module, line 2087

<?php
function date_format_locale($langcode = NULL, $type = NULL, $reset = FALSE) {
  static $formats;
  
  if ($reset || empty($formats)) {
    $formats = array();
    $result = db_query("SELECT format, type, language FROM {date_format_locale}");
    while ($object = db_fetch_object($result)) {
      if (!isset($formats[$object->language])) {
        $formats[$object->language] = array();
      }
      $formats[$object->language][$object->type] = $object->format;
    }
  }

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

  return FALSE;
}
?>

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.
  • You may post code using <code>...</code> (generic) or <?php ... ?> (highlighted PHP) tags.
  • Web page addresses and e-mail addresses turn into links automatically.

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Image CAPTCHA
Enter the characters shown in the image.