Last updated August 10, 2012. Created by tax14 on February 25, 2011.
Edited by brankoc. Log in to edit this page.

When you create an article or page in Drupal 7, by default, it displays Author and Date information after the title, something like:

published by admin on Thu, 02/17/2011 - 11:08

If you don't want to see this information, disable the Display Settings option for the corresponding content type with these steps:

1. Log-in as Admin and choose Structure, Content types and click edit (under Operations) for the corresponding content type (e.g. Article).
2. Click Display Settings and un-check Display author and date information check box.
3. Save settings by clicking the Save Content Type button.

Now, the author and date information will not be displayed for the corresponding content type.

How about if you want to display the date information but not the author information, e.g. you want to see something like:

Posted: February 23, 2011

To accomplish this,

1. Enable Display Settings for the corresponding content type.
2. Edit the node.tpl.php file of the corresponding theme you are using, e.g. themes\bartik\templates\node.tpl.php and located the following command:
print $submitted;

3. Now replace this command with the following code:
// print $submitted;
if ($submitted) {
echo "Posted: " . date( "F j, Y",$node->created);
}

4. Save the file and you should see the submitted information in the desired format. Of course, you can use a different date format or add additional node details.

Modules

Modules that let you perform the operations above without programming skills:

  • Submitted By (the D7 version is under development, but is already usable - check the Issue list for known quirks)

Looking for support? Visit the Drupal.org forums, or join #drupal-support in IRC.

Comments

If you need to format the dates with an specific language you can't use the format_date function provided by Drupal. (http://api.drupal.org/api/drupal/includes--common.inc/function/format_date)

In my case I use a code likes:

format_date($node->created, $type = 'medium', $format = 'F j - Y', $timezone = NULL, $langcode = 'es')

I hope that it will be helpful for developers in Latam or other countries.

After i am adding some content and in authoring information adding time , it automatically sets to am.. i want to have it in pm, manually.. can you plz help??

himani

Another option is to use hook_preprocess_node in your template.php file:

<?php
THEME_preprocess_node
(&$variables) {
  if (
$variables['submitted']) {
   
$variables['submitted'] = t('Posted: !datetime', array( '!datetime' => format_date($variables['node']->created, 'custom', 'F j, Y')));
  }
}
?>

This provides a much cleaner override of the submitted variable for nodes.

Wondering aloud - why doesn't "display settings" have two check boxes - one for Author and one for Date - after all they start off as two fields.

peter davis : fuzion : connect.campaign.communicate : www.fuzion.co.nz

+1. Also seems like these checkboxes should be on the Manage Display page (admin/structure/types/manage/page/display) instead of the Edit page.

Yes, on the manage display page and as two separate checkboxes and with a dropdown to select the different formats please, that would make way more sense and be really flexible.

Agreed. It seems nonsensical to combine these fields.

Mike

--
http://noseyparka.me.uk/ - I build web sites and teach people how to build web sites.

it would be a nice usability improvement

btw I just came across the Display Suite module which changes the "manage display" page to allow exactly for that and moving title, links, comments and way more useful features like changing/resetting field and views templates, linking between displays, dynamic & block fields, moving fields to a block just to name a few. Imho could replace views in those cases where you mainly use views to have more control over the output...

Thank you for information :)

I had DS installed anyway, and by doing it via Display Suite I don't have to hack any templates, awesome.

Can i ask what the code would be to get author only instead of date ?

something like that, i presume :

if ($submitted) {
echo "Author: " . ???( "???",$node->created);
}

but what about "???"

CC

i answer to myself : there is nothing easier ... when you are using another language !!!

you go in site building / translate interface / search
and you search :
string contains : -->"Posted*" (* the translated term in the other language you use)
in "Built-in interface" you find your text
you edit and you find :
"Submitted by !username on @datetime" (translated)
you suppress the one you don't want anymore, register : it's ready !

CC

Hey there!

I don't understand how I can change that for a specific custom content type. What's the corresponding file name? Let's say my content type is called "mynews".

Thanks

~Eduardo~

I did it with CSS by using a new style for the content type's class. I tried Display Suite but couldn't find a the place to configure the author/date for my custom content type. Anyway, maybe I'll try it later with Panels...

~Eduardo~

In your theme, you need to make a copy of node.tpl.php. Then rename this file node--your-content-type-machine-name.tpl.php. So in your case, the new file would be named node--mynews.tpl.php.

Here's a detailed explanation of customizing the "Submitted by [name] on [date]" string.

There are two places you can modify this string:
1 ) Inside of template.php in your theme, edit (or add) the following function:

<?php
function THEMENAME_preprocess_node(&$variables) {
 
$variables['submitted'] = t('Submitted by !username on !datetime', array('!username' => $variables['name'], '!datetime' => $variables['date']));
}
?>

Or you can modify node.tpl.php and change the $submitted variable:
<?php
  $submitted
= t('Submitted by !username on !datetime', array('!username' => $name, '!datetime' => $date));
?>

You can customize those parts to change the wording "Submitted by", or only display the username or date. The following examples are using the template.php approach. For the node.tpl.php format, you would change $variables['myvariablename'] to $myvariablename.

If you only want the username:

<?php
  $variables
['submitted'] = t('Submitted by !username', array('!username' => $variables['name']));
?>

And only the date:

<?php
  $variables
['submitted'] = t('Submitted on !datetime', array('!datetime' => $variables['date']));
?>

(and of course you can change the string "Submitted on" to whatever you like.)

To customize the date format, the recommended solution is to use one of the predefined formats under Configuration > Regional and Language > Date and Time (Drupal 7.x) or Site Configuration > Date and Time (Drupal 6.x). Once this is done, you can then use those predefined formats in your code with format_date(). Refer to the Drupal API for full details on the format_date() function.

To use one of the formats that you set up above:

<?php
  $variables
['date'] = format_date($variables['node']->created, 'format_type'));
 
// Where 'format_type' is one of: 'long', 'medium' or 'short'
?>

You can also use 'custom' as the format type, and specify your own format in the third parameter:

<?php
  $variables
['date'] = format_date($variables['node']->created, 'custom', 'F j, Y');
?>

The third parameter is a combination of date parts. You can view a full list here: http://www.b2ben.com/php/phpdate.php or http://www.php.net/manual/en/function.date.php

A little error has made her way thru copy&paste functionality:

<?php
  $variables
['date'] = format_date($variables['node']->created, 'format_type');
 
// Where 'format_type' is one of: 'long', 'medium' or 'short'
?>

only 1 parenthesis at the end...
But still a big thank to @hargobind for the detailed explanation !

David THOMAS
http://www.smol.org

I edited the theme template.php (just to remind me) from drupal root ./sites/all/themes/"theme name"/

I added selfcreated time format named suomilyhyt using Drupal 7 admin panels as noted before

// Muokataan päiväformaatti vastaamaan suomi asetuksia.
$variables['date'] = format_date($variables['node']->created, 'suomilyhyt');

// Add pubdate to submitted variable.
$variables['pubdate'] = 'created, 'custom', 'c') . '">' . $variables['date'] . '';
if ($variables['display_submitted']) {
$variables['submitted'] = t('Submitted by !username on !datetime', array('!username' => $variables['name'], '!datetime' => $variables['pubdate']));
}

Worked for me just fine. I am a little bit rust on php and so on. I am not sure about possible error handling if variable date is not set but I have to start learning from some where.

Thanks a lot for solution. :)

Learning to get a job.
petrieskelinen.info

So glad it was this easy! :D Thanks a bunch

How to Control/Modify Display Settings (Author and Date Information) on Posts

Does anyone know how to do this in Drupal 6?

Diana

You can use the MYTHEMENAME_preprocess_node function in template.php also in drupal 6. Maybe the way to alter the $variables['submitted'] will be slightly different.

David THOMAS
http://www.smol.org

I just made a views block containing a post date field, and put a node id contextual filter on it so it prints the date of each page. Here is my view:

$view = new view();
$view->name = 'post_date';
$view->description = '';
$view->tag = 'default';
$view->base_table = 'node';
$view->human_name = 'post date';
$view->core = 7;
$view->api_version = '3.0';
$view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */
/* Display: Master */
$handler = $view->new_display('default', 'Master', 'default');
$handler->display->display_options['use_more_always'] = FALSE;
$handler->display->display_options['access']['type'] = 'perm';
$handler->display->display_options['cache']['type'] = 'none';
$handler->display->display_options['query']['type'] = 'views_query';
$handler->display->display_options['exposed_form']['type'] = 'basic';
$handler->display->display_options['pager']['type'] = 'some';
$handler->display->display_options['pager']['options']['items_per_page'] = '1';
$handler->display->display_options['style_plugin'] = 'default';
$handler->display->display_options['row_plugin'] = 'fields';
/* Field: Content: Post date */
$handler->display->display_options['fields']['created']['id'] = 'created';
$handler->display->display_options['fields']['created']['table'] = 'node';
$handler->display->display_options['fields']['created']['field'] = 'created';
$handler->display->display_options['fields']['created']['label'] = '';
$handler->display->display_options['fields']['created']['element_label_colon'] = FALSE;
$handler->display->display_options['fields']['created']['date_format'] = 'long';
/* Contextual filter: Content: Nid */
$handler->display->display_options['arguments']['nid']['id'] = 'nid';
$handler->display->display_options['arguments']['nid']['table'] = 'node';
$handler->display->display_options['arguments']['nid']['field'] = 'nid';
$handler->display->display_options['arguments']['nid']['default_action'] = 'default';
$handler->display->display_options['arguments']['nid']['default_argument_type'] = 'node';
$handler->display->display_options['arguments']['nid']['summary']['number_of_records'] = '0';
$handler->display->display_options['arguments']['nid']['summary']['format'] = 'default_summary';
$handler->display->display_options['arguments']['nid']['summary_options']['items_per_page'] = '25';
$handler->display->display_options['arguments']['nid']['specify_validation'] = TRUE;
/* Filter criterion: Content: Published */
$handler->display->display_options['filters']['status']['id'] = 'status';
$handler->display->display_options['filters']['status']['table'] = 'node';
$handler->display->display_options['filters']['status']['field'] = 'status';
$handler->display->display_options['filters']['status']['value'] = 1;
$handler->display->display_options['filters']['status']['group'] = 1;
$handler->display->display_options['filters']['status']['expose']['operator'] = FALSE;
/* Filter criterion: Content: Type */
$handler->display->display_options['filters']['type']['id'] = 'type';
$handler->display->display_options['filters']['type']['table'] = 'node';
$handler->display->display_options['filters']['type']['field'] = 'type';
$handler->display->display_options['filters']['type']['value'] = array(
  'page' => 'page',
  'product' => 'product',
);
/* Display: Block */
$handler = $view->new_display('block', 'Block', 'block');

  • The default node display for the date is the "Medium" format, found here: ./admin/config/regional/date-time
  • Add your own date format ("l, F jS, Y" for "Wednesday, January 8th, 2014") here: ./admin/config/regional/date-time/formats
  • Then change the "Medium" format to your newly created one.