I haven't been able to google my way out of this one.
What i need is to change the default date formatting for the "Authored on" field to DD/MM/YYYY

Thanks!

Comments

xl883c’s picture

Are you referring to the 'submitted by' line?

If so, you may find this helpful:
http://answers.oreilly.com/topic/1512-using-drupals-templatephp-for-over...

pbarnett’s picture

Shame that Blimey O'Reilly screwed up the php code printing!

The new function in template.php should be

function yourtheme_preprocess_node(&$vars) {
  // Change the submitted value to output like "Posted on 12/06/2008"
  $vars['submitted'] = t('Posted on ') . format_date($vars['node']->created, 'custom', 'd/m/Y');
}
handsofaten’s picture

This code is a bit sloppy, as it overrides theme settings which tell Drupal whether to display this at all. So if you are looking at a content type that is not set to display the "Submitted by..." info at all, this will stick it in there, ignoring the settings. The snippet below should respect the setting:

function yourtheme_preprocess_node(&$vars) {
  // Change the submitted value to output like "Posted on 12/06/2008"
  if(!empty($vars['submitted'])){
    $vars['submitted'] = t('Posted on ') . format_date($vars['node']->created, 'custom', 'd/m/Y');
  }
}
jnjn’s picture

Actually im refering to the field, when you edit/add a new story and click the "authoring information" tab.
There is a field called "Authored on" and below it says "Format: 2010-12-02 19:09:07 +0100"

I would like to have this field be DD/MM/YYYY instead

pbarnett’s picture

The bit you're referring to is hardcoded in node.pages.inc and so can't be changed - well, it can, but any upgrade will overwrite the change, so hacking core modules is discouraged.

The code above will change the format of the 'Submitted by...' bit when actually viewing the story.

jnjn’s picture

Okay, thanks for the reply. Think i will just leave it as is then, and used the code posted to output correct format.

Thanks guys =)

interlated’s picture

If you are coming here from google then changing the format on this field date_popup_authored.