Support

Home Forums Event Espresso Premium PHP Echo Date and Time for EE4

PHP Echo Date and Time for EE4

Posted: January 15, 2020 at 10:24 pm


thenicam

January 15, 2020 at 10:24 pm

So I’m trying to echo the start date similar to how it was suggested in this past forum post (except I’m using EE4).

https://eventespresso.com/topic/how-do-i-echo-out-the-start-date-time-end-date-time/

I’m trying to add a section on my homepage that list the most recent upcoming event. I’m able to get the title and description displayed fine but cannot figure out how to get the date to display. Everytime I use the “event_date_display” it crashed my page.

Here is the code that is working with just title and description but without the date:

http://wpbin.io/2dxha0

What should I be doing?

  • This topic was modified 4 years, 3 months ago by  Josh. Reason: removed large block of code and replaced with a link to a code bin


thenicam

January 16, 2020 at 1:08 am

Sorry the code didn’t transfer correctly. If I need to resubmit the code let me know.


Josh

  • Support Staff

January 16, 2020 at 7:38 am

Hi,

Within the if ( $event instanceof EE_Event ) {

you can do:

$primary_datetime = clone $event->primary_datetime();
if($primary_datetime instanceof EE_Datetime) {
 echo $primary_datetime->start_date();
}

FYI the reason your site crashed when you tried event_date_display() is because that’s an Event Espresso 3 function and isn’t provided in Event Espresso 4.

The support post ‘PHP Echo Date and Time for EE4’ is closed to new replies.

Have a question about this support post? Create a new support post in our support forums and include a link to this existing support post so we can help you.

Event Espresso