5

I'm new to drupal but learning quickly. I've got drupal 7 and I'm working on creating a theme based on Zen's starterkit sub-theme. I'm trying to find where I can customize the "Submitted by" line.

The default looks like this:

Submitted by kenny on Sun, 05/13/2012 - 18:33

I'd like to change it so it simply says the date in a nice format (no user name, no time).

Sunday, May 13th, 2012

How and where can I change this?

Kenny Wyland
  • 20,844
  • 26
  • 117
  • 229

2 Answers2

18

In your template.php file (of the Zen sub theme), put this.

function mytheme_preprocess_node(&$vars, $hook) {
$vars['submitted'] = date("l, M jS, Y", $vars['created']);
}
AKS
  • 4,618
  • 2
  • 29
  • 48
  • It should be noted that this solution does not seem to take the site language into account. E.g. if my site is in French, the name of the day will be shown in English. – s427 Jan 22 '19 at 14:30
0

If you want to set "Submitted by " and change date formate for specific content type then you can also change your tpl file like

if your content type is "blog"

then create node--blog.tpl.php

<?php if ($display_submitted): ?>    
  <p class="submitted">
    <?php $user = user_load($node->uid); ?>
            <?php $username=$user->name; ?>
    <?php print t("Written"); ?>
    <?php print $username ?>
    <time pubdate datetime="<?php print $submitted_pubdate; ?>">
    <?php $date = date("d.n.Y", $node->created); ?>
    <?php print "<br>".$date; ?>
    </time>
  </p>
  <?php endif; ?>
Ajay Gadhavana
  • 415
  • 5
  • 5