I am working on a site with a blog, and on the blog I would like to show the submitted by with the date only, not time.

Can anyone help with this?

Drupal 7 by the way.

Thanks.

Comments

theabacus’s picture

I looks like they changed it in Drupal 7. It used to be that you had to use theme_node_submitted() (http://api.drupal.org/api/drupal/modules--node--node.module/function/the...) but, it is now a little easier.

1. You want to ONLY alter the blog template. So to do that you need to duplicate the node.tpl.php file in your template.
2. Rename the duplicate to node-blog.tpl.php (assuming that "blog" is the content type).
3. Clear your Drupal cache (/admin/settings/performance).
4. Now you can edit node-blog.tpl.php as needed. You will see the code:

  <?php if ($display_submitted): ?>
    <span class="submitted"><?php print $node->created; ?> — <?php print $name; ?></span>
  <?php endif; ?>

Change it to...

  <?php if ($display_submitted): ?>
    <span class="submitted"><?php print date("F j, Y", $node->created); ?> — <?php print $name; ?></span>
  <?php endif; ?>

The "F j, Y" part can be changed to match what format you want. See http://us.php.net/manual/en/function.date.php for specifics on what letters/values are available.

theabacus’s picture

Mmm...actually this is another/better way to do it. Follow the 4 steps above but add the following...

1. Go to admin/config/regional/date-time
2. Click on the "Formats" tab
3. Click "Add format"
4. Create a format string (see the link to the PHP manual in the field description).
5. Once the format is created, click on the "Types" tab.
6. Click "Add date type"
7. Date type name: dateonly
8. Date format: select the format you just made out of the date format drop down (it should be at the bottom)
9. Change

  <?php if ($display_submitted): ?>
    <span class="submitted"><?php print $node->created; ?> — <?php print $name; ?></span>
  <?php endif; ?>

to

  <?php if ($display_submitted): ?>
    <span class="submitted"><?php print format_date($node->created, "dateonly"); ?> — <?php print $name; ?></span>
  <?php endif; ?>
akael’s picture

You are amazing!

Thank you very much.

Bricks and Clicks Marketing’s picture

Thankee vicar!

Arp Laszlo
bricksandclicks.marketing
design / theming / development / consulting