0

I have a content type called news which I created a template for, node--news.tpl.php. In my template, I call the date field as follows:

<?php print render($content['field_news_date']);  ?>

It displays like so:

05/01/2015 - 15:25

I would like it to look like this:

1 May 2015

I need to be able to do so solely through the node template, as making changes directly in Drupal will affect other sites and that is not an option. Is there a way to do that?

1

Assuming you need a specific template, you could also use template.php. This is the preferred method to keep logic out of the template.

Using template.php, you can do a template_preprocess_field()

This overview does a nice job walking you through altering the date. Also, using php date() function you can alter the field to display as 1 May 2015 using l M Y

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.