Take the 2-minute tour ×
Drupal Answers is a question and answer site for Drupal developers and administrators. It's 100% free, no registration required.

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

<div>03/05/2013</div>

I want it to put out

<div>03</div>
<div>05</div>
<div>2013</div>

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
add comment

1 Answer

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
add comment

Your Answer

 
discard

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.