Drupal Answers is a question and answer site for Drupal developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a view which shows a couple of fields in a list. One of the fields is a date field. I'm trying to alter the output of this field so that I can control the day, month and year seperately. So instead of the view putting out


I want it to put out


I've already tried doing it with the use of custom date formats, then adding the date field three times to the view, each with a different date format. Excluding the first two fields from display and rewriting the output result of the third field with tokens. But then the day/month/year is wrapped in a span tag when I just want the raw value.

Should I use a template file, preprocess function,... for this?

Thank you.

share|improve this question
up vote 1 down vote accepted

This way requires installing Views PHP:

  1. Hide (do not display) the date field
  2. Create 3 more fields (day, month, year)
  3. Rewrite the value of these fields, using the the token of the hidden date field, and custom PHP code. This example is for the year field:

    echo date('Y', strtotime([token_datefield]));
share|improve this answer
Thanks for your response. I got it to work. – Smos Mar 7 '13 at 15:51

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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