Support

Home Forums Event Espresso Premium EE4 espresso_event_date() Format Syntax

EE4 espresso_event_date() Format Syntax

Posted: October 23, 2018 at 5:53 pm

Viewing 1 reply thread


Peak Creative

October 23, 2018 at 5:53 pm

I have waded through a LOT of documentation, posts on this forum, etc. and cannot figure out the syntax/approach for this. I have copied content-espresso-events-datetimes.php to my child theme and it is responding to changes. However, I’m needing to customize the startdate output.

If I use:

espresso_event_date();

for the non-single pages like this:

if (is_single()) {
	espresso_list_of_event_dates( $post->ID );
} else {
	espresso_event_date();
}

I get October 23, 2018 5:30 PM format, which is fine but I want to customize that a bit. I’ve looked everywhere for arguments for espresso_event_date() but can’t find a list anywhere to change the output. Anything I have found is either EE3 syntax or just blows the page up in various ways.

Is there a way to format that start date (using something else besides espresso_event_date(), keeping in mind this is being done within the confines of the content-espresso_events-datetimes.php template in a child theme?


Tony

  • Support Staff

October 24, 2018 at 4:20 am

Hi there,

espresso_event_date() is a template tag and sits within \event-espresso-core-reg\public\template_tags.php

So looking in that file you’ll find this:

function espresso_event_date( $date_format = '', $time_format = '', $EVT_ID = FALSE, $echo = TRUE ) {
	$date_format = ! empty( $date_format ) ? $date_format : get_option( 'date_format' );
	$time_format = ! empty( $time_format ) ? $time_format : get_option( 'time_format' );
	$date_format = apply_filters( 'FHEE__espresso_event_date__date_format', $date_format );
	$time_format = apply_filters( 'FHEE__espresso_event_date__time_format', $time_format );
	if($echo){
		echo EEH_Event_View::the_event_date( $date_format, $time_format, $EVT_ID );
		return '';
	}
	return EEH_Event_View::the_event_date( $date_format, $time_format, $EVT_ID );

}

Which means you can pass the date format and time format to the functions like so:

espresso_event_date('{date_format}', '{time_format}');

By default, the function uses the format set in your sites general settings but the above sets the format for that specific function call.

May I ask, what exactly are you wanting to output? espresso_event_date() pulls the ‘primary’ datetime for the event, meaning the first datetime at the top of the list within the editor.

Viewing 1 reply thread

The support post ‘EE4 espresso_event_date() Format Syntax’ 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