function format_date


Error message

User warning: The following module is missing from the file system: theme/theme. For information about how to fix this, see the documentation page. in _drupal_trigger_error_with_delayed_logging() (line 1156 of /var/www/html/elmsln_community/
cis7 format_date($timestamp, $type = 'medium', $format = '', $timezone = NULL, $langcode = NULL)
cle7 format_date($timestamp, $type = 'medium', $format = '', $timezone = NULL, $langcode = NULL)
elmsmedia7 format_date($timestamp, $type = 'medium', $format = '', $timezone = NULL, $langcode = NULL)
icor7 format_date($timestamp, $type = 'medium', $format = '', $timezone = NULL, $langcode = NULL)
meedjum_blog7 format_date($timestamp, $type = 'medium', $format = '', $timezone = NULL, $langcode = NULL)
mooc7 format_date($timestamp, $type = 'medium', $format = '', $timezone = NULL, $langcode = NULL)

Formats a date, using a date type or a custom date format string.


$timestamp: A UNIX timestamp to format.

$type: (optional) The format to use, one of:

  • 'short', 'medium', or 'long' (the corresponding built-in date formats).
  • The name of a date type defined by a module in hook_date_format_types(), if it's been assigned a format.
  • The machine name of an administrator-defined date format.
  • 'custom', to use $format.

Defaults to 'medium'.

$format: (optional) If $type is 'custom', a PHP date format string suitable for input to date(). Use a backslash to escape ordinary text, so it does not get interpreted as date format characters.

$timezone: (optional) Time zone identifier, as described at Defaults to the time zone used to display the page.

$langcode: (optional) Language code to translate to. Defaults to the language used to display the page.

Return value

A translated date string in the requested format.

Related topics

107 calls to format_date()
adaptivetheme_preprocess_aggregator_item in sites/all/themes/ulmus/adaptivetheme/at_core/inc/
Preprocess variables for aggregator-item.tpl.php
adaptivetheme_preprocess_comment in sites/all/themes/ulmus/adaptivetheme/at_core/inc/
Preprocess variables for comment.tpl.php
adaptivetheme_preprocess_node in sites/all/themes/ulmus/adaptivetheme/at_core/inc/
Preprocess variables for node.tpl.php
backup_migrate_drush_destination_files in sites/all/modules/ulmus/backup_migrate/includes/
Get a list of files in a given destination
backup_migrate_perform_backup in sites/all/modules/ulmus/backup_migrate/backup_migrate.module
Perform a backup with the given settings.

... See full list


includes/, line 1962
Common functions that many Drupal modules will need to reference.


function format_date($timestamp, $type = 'medium', $format = '', $timezone = NULL, $langcode = NULL) {
  // Use the advanced drupal_static() pattern, since this is called very often.
  static $drupal_static_fast;
  if (!isset($drupal_static_fast)) {
    $drupal_static_fast['timezones'] = &drupal_static(__FUNCTION__);
  $timezones = &$drupal_static_fast['timezones'];

  if (!isset($timezone)) {
    $timezone = date_default_timezone_get();
  // Store DateTimeZone objects in an array rather than repeatedly
  // constructing identical objects over the life of a request.
  if (!isset($timezones[$timezone])) {
    $timezones[$timezone] = timezone_open($timezone);

  // Use the default langcode if none is set.
  global $language;
  if (empty($langcode)) {
    $langcode = isset($language->language) ? $language->language : 'en';

  switch ($type) {
    case 'short':
      $format = variable_get('date_format_short', 'm/d/Y - H:i');

    case 'long':
      $format = variable_get('date_format_long', 'l, F j, Y - H:i');

    case 'custom':
      // No change to format.

    case 'medium':
      // Retrieve the format of the custom $type passed.
      if ($type != 'medium') {
        $format = variable_get('date_format_' . $type, '');
      // Fall back to 'medium'.
      if ($format === '') {
        $format = variable_get('date_format_medium', 'D, m/d/Y - H:i');

  // Create a DateTime object from the timestamp.
  $date_time = date_create('@' . $timestamp);
  // Set the time zone for the DateTime object.
  date_timezone_set($date_time, $timezones[$timezone]);

  // Encode markers that should be translated. 'A' becomes '\xEF\AA\xFF'.
  // xEF and xFF are invalid UTF-8 sequences, and we assume they are not in the
  // input string.
  // Paired backslashes are isolated to prevent errors in read-ahead evaluation.
  // The read-ahead expression ensures that A matches, but not \A.
  $format = preg_replace(array('/\\\\\\\\/', '/(?<!\\\\)([AaeDlMTF])/'), array("\xEF\\\\\\\\\xFF", "\xEF\\\\\$1\$1\xFF"), $format);

  // Call date_format().
  $format = date_format($date_time, $format);

  // Pass the langcode to _format_date_callback().
  _format_date_callback(NULL, $langcode);

  // Translate the marked sequences.
  return preg_replace_callback('/\xEF([AaeDlMTF]?)(.*?)\xFF/', '_format_date_callback', $format);



Error message

  • Warning: Cannot modify header information - headers already sent by (output started at /var/www/html/elmsln_community/ in drupal_send_headers() (line 1499 of /var/www/html/elmsln_community/
  • Error: Call to undefined function apc_delete() in DrupalAPCCache->clear() (line 289 of /var/www/html/elmsln_community/
The website encountered an unexpected error. Please try again later.