Support

Home Forums Event Espresso Premium Event Listing with Time

Event Listing with Time

Posted: October 26, 2013 at 5:38 pm


Scott Ficek

October 26, 2013 at 5:38 pm

I recently asked about how to add the time to the event listing. You can find that thread here:
https://eventespresso.com/topic/event-listing-with-more-details/

Right now it shows in military time. I tried to modify the code slightly to use AM & PM, but it now just always displays 6:00pm. Must be a syntax thing. Any ideas:

<p id=”p_event_start_time-<?php echo $event_id ?>” class=”event_start_time”><span class=”section-title”><?php echo __(‘Start Time: ‘, ‘event_espresso’); ?></span><?php echo date(“g:i a.”,$event->start_time) ?></p>


Dean

October 28, 2013 at 12:52 am

Hi Scott,

The issue here is that your trying to convert the format of a string, rather than time.

At the very least you will need to strtotime the start_time.

I would suggest something like this, it uses the default WordPress time format:

<?php $timeformat = get_option('time_format'); $new_start_time = date($timeformat, strtotime($event->start_time)); ?>

<p id="p_event_start_time-<?php echo $event_id ?>" class="event_start_time"><span class="section-title"><?php echo __('Start Time: ', 'event_espresso'); ?></span><?php echo $new_start_time; ?></p>

http://php.net/manual/en/function.strtotime.php


Scott Ficek

October 28, 2013 at 5:43 pm

Woohoo! That worked.

Thank you.

The support post ‘Event Listing with Time’ 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