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.


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]));

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.