I have created content type for an events in which I mentioned multiple values for date field. I want to display date like Nov. 2, 6 & 8 or Nov. 2-5, 12 2014 & Jan 22 2015

After some research I am able to create a view of event date field like

Nov 23 2014, Nov 26 2014, Nov 30 2014, Jan 03 2015 to Jan 05 2015

But still not getting format I want like

Nov 23, 26, 30 2014 & Jan 03-05 2015

  • It's about to 4 days that I am working on it, still not get perfect guidence – CodeLearner20 Nov 26 '14 at 11:56

If you are comfortable with coding then go for template file changes. You have to do changes in node.tpl.php.

Else you can do also without coding refer https://stackoverflow.com/questions/8375674/how-can-a-custom-drupal-date-format-be-added

If you have created view for event display then it is easy to display date field as you want. Go to date fields setting. There is a option for formatter. Like below screenshot. Here you can add custom date display format.

enter image description here

| improve this answer | |
  • Ok let me know if you are getting any issue in this scenarios. – DRUPWAY Nov 22 '14 at 6:18
  • I don't think adding a custom dare format is going to help here, as there's conditional logic necessary to collate dates by arbitrary criteria. Given that your incidence and interval pattern is variable, my suggestion would be to allow the user to input multiple date values and then loop through those via theme preprocessing functions or in a specific node--type or field-- template override rather than node.tpl.php. If you will be testing for date conflicts, that may further complicate solutions proposed here. – murraybiscuit Nov 22 '14 at 9:53
  • @murraybiscuit is there any tutorial that I can follow for this? – CodeLearner20 Nov 26 '14 at 11:55
  • The solution gets pretty complicated depending on the parameters. Getting the fields out of the node and grouped into a multi-dimensional array is easy. Grouping the array by year and then by month gets more tricky. Then you sort the array. Then you loop through to combine it. What if a date falls across two months? What if it falls across two years? I'd say the Drupal parts of this are easy. The php stuff is where it's going to require some fiddly conditional logic & exceptions. – murraybiscuit Nov 26 '14 at 19:10
  • @murraybiscuit, Ok I will go through this, Big Thanks for your support :) – CodeLearner20 Nov 27 '14 at 6:51

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.