Having a small issue trying to display my date field in a certain way inside my EFQ.
I setup a event content type and set DATE format, worked very well using views but defaults to something else in EFQ.
I was looking at this and lots of other handy PHP functions though I 'm not sure how I add this to the code.
Just wondering how I would tie this in with the output, the field_event_date_and_time field ?
A wild guess, but I think wrapping $node->field_event_date_and_time['und'][0]['value']
with a strtotime to get it into a timestamp,
then wrapping that with date to format it would work.
Notice: A non well formed numeric value encountered in eventlist_block_eventlist() (line 88 of…
Barry
Just so things are clear
The correct date format is already setup inside my event content type and all my event nodes display the correct date format.
I also have the Date and time configured inside my main config - Long Medium Short to just how I need it.
What Mittineague has suggested is the wrong way to do this in Drupal. In Drupal you essentially have a list of date types that map to any type of display. The advantage of this is if the display needs to change you just change the configuration for a single date type and it changes it everywhere. While what is suggested works it is wrong in terms of how things *should be done in Drupal. With that said, what is the name of your date format?
The code would go in your module, something ike this:
I see what you mean oddz and makes sense that we already have the date type configured.
So would this work in a similar way to a CSS class, something we can use over and over wherever its needed?
Warning: date_format() expects parameter 1 to be DateTime, string given in eventlist_block_eventlist() (line 89 of
I also noticed that the date types all have month, date, year, time etc. (it doesn’t give you the option to just select one)
What if I only want to show the time?
Thanks, Barry
UPDATE
I thought computerbarry had tried the Drupal way but for some reason it didn’t work with EFQ and needed to use “raw” PHP
Thats exactly right Mittineague.
And with your help we’ve realised what the correct way is while learning some handy PHP also.
PITA - pain in the *** i.e. in this case, messy, confusing, not elegant, and most likely not the best way to go about it.(maintenance problems)
As things stand, calling the date type doesn’t work as outlined in post #15 above and I’m not sure how to just select the time from this date type because want I can see date types don’t allow you to create a time only. This is another problem, if I get oddz solution to work, how do I select only the time? Only the month etc.
Yes, I agree Mittineague’s suggestion to use strtotime is the purest solution. strtotime() + date() were a favorite combination when I used to do a lot of straight PHP date manipulation.