function hook_date_format_types

×

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/api.elmsln.org/includes/bootstrap.inc).
cis7 system.api.php hook_date_format_types()
cle7 system.api.php hook_date_format_types()
elmsmedia7 system.api.php hook_date_format_types()
icor7 system.api.php hook_date_format_types()
meedjum_blog7 system.api.php hook_date_format_types()
mooc7 system.api.php hook_date_format_types()

Define additional date types.

Next to the 'long', 'medium' and 'short' date types defined in core, any module can define additional types that can be used when displaying dates, by implementing this hook. A date type is basically just a name for a date format.

Date types are used in the administration interface: a user can assign date format types defined in hook_date_formats() to date types defined in this hook. Once a format has been assigned by a user, the machine name of a type can be used in the format_date() function to format a date using the chosen formatting.

To define a date type in a module and make sure a format has been assigned to it, without requiring a user to visit the administrative interface, use

variable_set('date_format_' . $type, $format); 

where $type is the machine-readable name defined here, and $format is a PHP date format string.

To avoid namespace collisions with date types defined by other modules, it is recommended that each date type starts with the module name. A date type can consist of letters, numbers and underscores.

Return value

An array of date types where the keys are the machine-readable names and the values are the human-readable labels.

See also

hook_date_formats()

format_date()

Related topics

2 functions implement hook_date_format_types()

Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.

system_date_format_types in modules/system/system.module
Implements hook_date_format_types().
token_test_date_format_types in sites/all/modules/ulmus/token/tests/token_test.module
Implements hook_date_format_types().
1 invocation of hook_date_format_types()
_system_date_format_types_build in modules/system/system.module
Builds and returns information about available date types.

File

modules/system/system.api.php, line 4036
Hooks provided by Drupal core and the System module.

Code

function hook_date_format_types() {
  // Define the core date format types.
  return array(
    'long' => t('Long'),
    'medium' => t('Medium'),
    'short' => t('Short'),
  );
}
Error | ELMSLN API

Error

×

Error message

  • Warning: Cannot modify header information - headers already sent by (output started at /var/www/html/elmsln_community/api.elmsln.org/includes/common.inc:2791) in drupal_send_headers() (line 1499 of /var/www/html/elmsln_community/api.elmsln.org/includes/bootstrap.inc).
  • Error: Call to undefined function apc_delete() in DrupalAPCCache->clear() (line 289 of /var/www/html/elmsln_community/api.elmsln.org/sites/all/modules/apc/drupal_apc_cache.inc).
The website encountered an unexpected error. Please try again later.