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 days, 17 hours 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.

You must be logged in to reply to this support post. Sign In or Register for an Account

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: publish

Updated by  Josh 4 days, 17 hours ago ago

Topic Tags

Notifications

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