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


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).

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:

What should I be doing?

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


January 16, 2020 at 1:08 am

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


  • Support Staff

January 16, 2020 at 7:38 am


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.

Support forum for Event Espresso 3 and Event Espresso 4.
Documentation for EE3 and EE4
Documentation for Event Espresso 3 Documentation for Event Espresso 4

Status: closed

Updated by  Josh 6 months, 3 weeks ago ago

Topic Tags


This topic is: not resolved
Do NOT follow this link or you will be banned from the site!