Support

Home Forums Event Espresso Premium EE4 – Accessing Event Datetime

EE4 – Accessing Event Datetime

Posted: May 5, 2014 at 5:22 pm


Paul Doyle

May 5, 2014 at 5:22 pm

Hi,

I’m trying to create a custom weekly calendar from events which all have single Datetimes, and all events span 6 – 8 weeks (they are courses of weekly classes), I need to access and test the following.

1. Event Start – Day
2. Event Start – Time
3. Event Start – Date
4. Event End – Time
5. Event End – Date

I see that espresso_event_date(); displays the start time and date but I’m not sure how to break the date up into the pieces so I can test and display something like….

All events on Monday, orderby time, if now is after Event Start Date and before Event Start End. I also need to access the Event Start Time and Event End Time so I can calculate the duration of a single class.

I’ve looked at ee4-themes-templates but again I’m in need of a little help.

Many Thanks!


Sidney Harrell

May 6, 2014 at 11:25 am

Instead of using espresso_event_date();, use espresso_event_date_obj();, like so:

$datetime = espresso_event_date_obj($post->ID);
$start_day = $datetime->start_date('l');
$start_time = $datetime->start_time('g:i a');
$start_date = $datetime->start_date('F j, Y');
$end_time = $datetime->end_time('g:i a');
$end_date = $datetime->end_date('F j, Y');

Note that you may want to vary the format requested, so that if you are trying to order by time, you would want to use 24 hour time. (http://www.php.net/manual/en/function.date.php)


Paul Doyle

May 7, 2014 at 5:55 am

Prefect …. Thanks Sidney 🙂

The support post ‘EE4 – Accessing Event Datetime’ 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