How do I add date formats to appear in the short/medium/long date pull downs on the settings page? Is this the correct way to introduce a new date format into your site? I've searched the forums but it doesn't seem to be mentioned anywhere.


platform8’s picture


mooffie’s picture

I remember reading that Drupal will have this feature someday.

Meanwhile, if you want to customize one, or all, of these three date formats, do the following.

These formats are stored in three Drupal variables: date_format_short, date_format_long, date_format_medium.

You can override these variable in your settings.php file (which resides somewhere in the 'sites' subdir). Open this file in a text-editor, scroll to its bottom and there you'll find a "Variable overrides" sections. Un-comment the $conf array and add to it one, or all, of the follwing lines:

'date_format_short' => 'm/d/Y - H:i',
'date_format_long' => 'l, F j, Y - H:i',
'date_format_medium' => 'D, m/d/Y - H:i',

The values to the right of the arrows have the syntax described in PHP's date() manual page.

Chill35’s picture

I will edit the date_format_short because it makes no sense (to me anyway) to include time of day, among other things.

You can call format_date with a custom flag and then use regular PHP syntax for date, in case this may be useful, just to complement the info given here.

For example (from my node.tpl.php file) :

print format_date($node->created, 'custom', 'l, j M Y');

Source :

format_date($timestamp, $type = 'medium', $format = '', $timezone = NULL)

And to put even more info in one place :

$type The format to use. Can be "small", "medium" or "large" for the preconfigured date formats. If "custom" is specified, then $format is required as well.

$format A PHP date format string as required by date(). A backslash should be used before a character to avoid interpreting the character as part of a date format.

Who am I | Where are we
11 heavens

platform8’s picture

That's what I was looking for, cheers.