Support

Home Forums Event Espresso Premium Showing start and end time on [ESPRESSO_MY_EVENTS] ticket table

Showing start and end time on [ESPRESSO_MY_EVENTS] ticket table

Posted: March 16, 2016 at 3:42 pm


eddy@mibeachclub.com

March 16, 2016 at 3:42 pm

I’m modifying the display of the event list by user and wanted to show the event information like this:

My Event Name
My Venue Name
March 1 – June 1, 2016
4:00pm – 6:00pm

I’m having trouble grabbing the ticket start and end time. How would I do this?

Thank you!


Tony

  • Support Staff

March 17, 2016 at 3:22 am

Hi there,

Within [ESPRESSO_MY_EVENTS] which template are you using?

The ticket start/end times set within the event are the sale dates, is that what you are looking to display or the event dates that they will be attending? (which would be from the datetime(s) the ticket is assigned to)


eddy@mibeachclub.com

March 17, 2016 at 12:40 pm

Hi,

I’m using content-espresso_my_events-event_section_tickets.template.php which I’ve copied into uploads -> espresso -> templates. I’m looking to display the event times for the event they will be attending.

I see this line:

<?php echo $ticket instanceof EE_Ticket ? $ticket->date_range() : ''; ?>

but I’m not sure how to show the start time and end time below this date range.


Tony

  • Support Staff

March 17, 2016 at 2:13 pm

Take a look at the date_range() method within the EE_Ticket class, it looks like this:

public function date_range( $dt_frmt = '', $conjunction = ' - ' ) {
	$first_date = $this->first_datetime() instanceof EE_Datetime ? $this->first_datetime()->start_date( $dt_frmt ) : '';
	$last_date = $this->last_datetime() instanceof EE_Datetime ? $this->last_datetime()->end_date( $dt_frmt ) : '';

	return $first_date && $last_date ? $first_date . $conjunction  . $last_date : '';
}

You can do something very similar within the MY event template,

$first_datetime = $ticket->first_datetime();
$last_datetime = $ticket->last_datetime();

Both $first_datetime and $laste_datetime should be an instance of an EE_Datetime (you can double check with the same instanceof check above)

You can then use:

echo $first_datetime->start_time() . ' - ' . $first_datetime->end_time();

I would recommend installing something like Kint Debugger on the site which allows you to wrap variables within d(); and output information about the variable/object etc you passed, like this:

d($first_datetime);

Would show you all of the available properties and methods you can use on that object.


eddy@mibeachclub.com

March 17, 2016 at 5:44 pm

Thank you for this thorough explanation! Worked great!


Tony

  • Support Staff

March 18, 2016 at 3:57 am

You’re most welcome 🙂

The support post ‘Showing start and end time on [ESPRESSO_MY_EVENTS] ticket table’ 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