Support

Home Forums Event Espresso Premium Time format in Custom Template Display.

Time format in Custom Template Display.

Posted: July 24, 2015 at 1:22 pm

Viewing 6 reply threads


Renee deVilliers

July 24, 2015 at 1:22 pm

I am using [EVENT_CUSTOM_VIEW template_name=”events-table” category_identifier=”intermagility-nc” expired=”false”] in my page: http://www.allaboutdogs.ca/agility-class-list to call the lists. I have edited a custom template, and removed the VENUE column (we are always the same venue) and to ADD the Start time column and and End time Coloumn. The columns show up, however, the time format is not what I would like.

I would like the times for both start and end times to look like, for example: 6:30pm NOT in the current 24 hour clock format that is showing.

I am using the following code to insert the start and end times in my custom php file for the events-table template I created.

            			<td class="venue_title venue-<?php echo $event->id;?>"><?php echo stripslashes($event->start_time/*.' '.$event->start_time, get_option('date_format').' '.get_option('time_format')*/) ?></td>
                        <td class="venue_title venue-<?php echo $event->id;?>"><?php echo stripslashes($event->end_time/*.' '.$event->end_time, get_option('date_format').' '.get_option('time_format')*/) ?></td>

I am no php wizard, and understand that some code is commented out, but when I try to make the format work, it doesn’t. I have no idea what I need to tweek to correct the time format. Perhaps someone can provide the line code to make the time format show up correctly.

Please and thank you.


Renee deVilliers

July 25, 2015 at 5:34 am

An addendum to my original post, I would also like to know how to make the columns align from table to table. See page: http://www.allaboutdogs.ca/upcomingclasses
Where I have broken out our upcoming classes by category, and the table columns do not align among the various tables. Is there any way to achieve visual alignment without making the table non-responsive?

please advise.

Thanks


Tony

  • Support Staff

July 27, 2015 at 6:01 am

Hi Renee,

We generally do not provide customisations on the forums as it is not something we can support, however we can point you in the right direction.

I would like the times for both start and end times to look like, for example: 6:30pm NOT in the current 24 hour clock format that is showing.

You can use:

$datetime->e_start_time('g:i a');

To force the start_time to be displayed using a specific format.

‘g:i a’ is hours:mins am/pm

See here for more info on date format and which values to use:

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

So you can use something like:

<td class="start_time event-<?php echo $post->ID; ?>"><?php $datetime->e_start_time('g:i a'); ?></td>

Where I have broken out our upcoming classes by category, and the table columns do not align among the various tables. Is there any way to achieve visual alignment without making the table non-responsive?

Its because of the Event Title column adjusting based on the length of the event title. You’ll need to specify a size for all of the tables to use, so something like:

td.event_title {
    width: 25%;
}

Setting the size to a percentage should keep the table responsive.


Renee deVilliers

July 30, 2015 at 11:39 am

Tony, while I understand that “customizations” are generally not provided on the forums, I would argue that the code I am using was PROVIDED – I did not write it. I see code commented out in the snippet I provided to you, which already exists in the file.

I have tried to uncomment the correct php to no avail. But you give me something completely different, which is not working by the way – no matter what I do, so because it is live, I put it back to 24hour.

I do not have much experience using PHP and I would have assumed that if in fact there was comment out code, I could remove comments and the darn thing would work.

If I use what you gave me, the page just spins and loads nothing.

Please help me sort this out.

Thanks


Tony

  • Support Staff

July 30, 2015 at 12:11 pm

Any modification from the original behaviour of the plugin/template/code would be classed as customisation. The template you are using has had the start_time and end_time added to it, therefore the template is customised from the original.

Using built in functions within Event Espresso to display the data how you prefer is still considered customisation.

The reason my code did not work is I had assumed you were using EE4, your using EE3 so I do apologise.

So knowing that I had another look at the template.

You’ll need to change this code:

<td class="venue_title venue-<?php echo $event->id;?>"><?php echo stripslashes($event->start_time/*.' '.$event->start_time, get_option('date_format').' '.get_option('time_format')*/) ?></td>
                        <td class="venue_title venue-<?php echo $event->id;?>"><?php echo stripslashes($event->end_time/*.' '.$event->end_time, get_option('date_format').' '.get_option('time_format')*/) ?></td>

To something like this:

<td class="venue_title venue-<?php echo $event->id;?>"><?php echo event_date_display($event->start_time, 'g:i a') ?></td>
<td class="venue_title venue-<?php echo $event->id;?>"><?php echo event_date_display($event->end_time, 'g:i a') ?></td>

Which will output the table like this – http://take.ms/UE3Gn

Is that what you are looking for?

You may also want to change the class used on each of those rows, currently they both use ‘venue_title’ and ‘venue-{event_id}’, to target those using CSS you may want to change those to event_start_time and event_end_time or similar.


Renee deVilliers

July 31, 2015 at 7:21 pm

Tony, Thank you that worked great! Appreciate the assistance.


Tony

  • Support Staff

August 3, 2015 at 4:06 am

You’re most welcome, Renee.

I’ll mark this thread resolved.

Viewing 6 reply threads

The support post ‘Time format in Custom Template Display.’ 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