Support

Home Forums Event Espresso Premium Get Event Time Programatically

Get Event Time Programatically

Posted: September 3, 2019 at 3:28 am


apolloefx

September 3, 2019 at 3:28 am

Hi there,

How do I get the event date programmatically?


<?php the_time($date_format); ?>
<?php the_permalink(); ?>"><?php the_title(); ?>
<?php the_excerpt(); ?>

Currently my theme has the date in the excerpt but it has a bunch of other stuff and I can’t expose it on the final page.

$date_format); gives me the blog post date not the event date

thanks Jose


Tony

  • Support Staff

September 3, 2019 at 4:14 am

Hi there,

The ‘event date’ differs depending on your event set up, a single event can have multiple ‘datetimes’ within it and depending on how you use the datetimes you need the date varies.

We have some template tags for the event which may work depending on your use case, for example espresso_event_date() may work for you, it pulls the ‘primary dattime’ (the first datetime) from the event and uses the date from that.

You can see a list of the template tag functions we have available HERE.


apolloefx

September 4, 2019 at 3:03 am

hey Tony, thanks for this but I don’t get any information. I think the scope I am in doesn’t expose that information.


Tony

  • Support Staff

September 4, 2019 at 3:31 am

Where are you running the code?

I’m assuming you aren’t getting an undefined function error?

The helper methods do their best to try and figured out the event object you need using the global post, but if you can pass the ID of the post in your loop, or you can also pass the post ID when calling the function:

espresso_event_date( $date_format = '', $time_format = '', $EVT_ID = FALSE, $echo = TRUE )

So in the above espresso_event_date( '', '', get_the_ID() ) should work, but then so should the code without any parameters passed to it.


apolloefx

September 6, 2019 at 12:09 pm

SWEET! works thank you Tony =)

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  apolloefx 1 week, 6 days ago ago

Topic Tags

Notifications

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