Define additional date formats.
This hook is used to define the PHP date format strings that can be assigned to date types in the administrative interface. A module can provide date format strings for the core-provided date types ('long', 'medium', and 'short'), or for date types defined in hook_date_format_types() by itself or another module.
Since date formats can be locale-specific, you can specify the locales that each date format string applies to. There may be more than one locale for a format. There may also be more than one format for the same locale. For example d/m/Y and Y/m/d work equally well in some locales. You may wish to define some additional date formats that aren't specific to any one locale, for example, "Y m". For these cases, the 'locales' component of the return value should be omitted.
Providing a date format here does not normally assign the format to be used with the associated date type -- a user has to choose a format for each date type in the administrative interface. There is one exception: locale initialization chooses a locale-specific format for the three core-provided types (see locale_get_localized_date_format() for details). If your module needs to ensure that a date type it defines has a format associated with it, call
variable_set('date_format_' . $type, $format);
where $type is the machine-readable name defined in hook_date_format_types(), and $format is a PHP date format string.
A list of date formats to offer as choices in the administrative interface. Each date format is a keyed array consisting of three elements:
Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.
function hook_date_formats() {
return array(
array(
'type' => 'mymodule_extra_long',
'format' => 'l jS F Y H:i:s e',
'locales' => array(
'en-ie',
),
),
array(
'type' => 'mymodule_extra_long',
'format' => 'l jS F Y h:i:sa',
'locales' => array(
'en',
'en-us',
),
),
array(
'type' => 'short',
'format' => 'F Y',
'locales' => array(),
),
);
}