Support

Home Forums Event Espresso Premium All the same dates appear in the table view when date/time columns are separated

All the same dates appear in the table view when date/time columns are separated

Posted: March 8, 2016 at 1:44 pm


lee@safeswim.com

March 8, 2016 at 1:44 pm

I have my table view of events set up to where there is a column for date and time separated. All the dates however become March 8, when you click on the event the real date shows in the event ticket. Why is it doing that?

You can see a screen shot of it here:
https://www.cprtrainingpro.com/wp-admin/images/table001.png

I currently have the website updated with the a different table:
http://www.cprtrainingpros.com/find-a-class/

<td class=”start_date event-<?php echo $post->ID; ?>” data-value=”<?php echo $datetime->get_raw( ‘DTT_EVT_start’ ); ?>”><?php echo $startdate; ?></td>
<td class=”day_of_week event-<?php echo $post->ID; ?>”><?php espresso_event_date_range( ‘l’, ‘ ‘, ‘l’, ‘ ‘, $event->ID() ); ?></td>
<td class=”time event-<?php echo $post->ID; ?>”><?php espresso_event_date_range( ‘g:i a’, ‘ ‘, ‘ ‘, ‘ ‘, $event->ID() ); ?></td>
<td class=”venue_title event-<?php echo $post->ID; ?>”><?php espresso_venue_name( NULL, FALSE ); ?></td>


Lorenzo Orlando Caum

  • Support Staff

March 8, 2016 at 3:10 pm

Hello,

I have my table view of events set up to where there is a column for date and time separated. All the dates however become March 8, when you click on the event the real date shows in the event ticket. Why is it doing that?

We’ll need more information to share feedback. What is the page link from the screenshot so we can see the events list table?


Lorenzo


Josh

  • Support Staff

March 8, 2016 at 3:19 pm

Hi there,

Did you make any changes to the $startdate variable in your custom template?


lee@safeswim.com

March 8, 2016 at 9:56 pm

Hi,

No, I did not edit the $startdate, both files have the same code below:

$startdate = date_i18n( $date_format . ‘ ‘ . $time_format, strtotime( $datetime->start_date_and_time(‘Y-m-d’, ‘H:i:s’) ) );

<td class=”start_date event-<?php echo $post->ID; ?>” data-value=”<?php echo $datetime->get_raw( ‘DTT_EVT_start’ ); ?>”><?php echo $startdate; ?></td>

Unfortunately the classes are live now so I am unable to switch the code over. I could for a short period of time if we happen to be on at the same time tomorrow.

This would be the entire code for the table that I would like but is not showing the accurate dates:

<?php
// Options
$date_format = get_option( ‘date_format’ );
$time_format = get_option( ‘time_format’ );
// Load Venue View Helper
EE_Registry::instance()->load_helper(‘Venue_View’);
//Defaults
$reg_button_text = !isset($reg_button_text) ? __(‘Register’, ‘event_espresso’) : $reg_button_text;
$alt_button_text = !isset($alt_button_text) ? __(‘View Details’, ‘event_espresso’) : $alt_button_text;//For alternate registration pages
$sold_out_button_text = !isset($sold_out_button_text) ? __(‘Sold Out’, ‘event_espresso’) : $sold_out_button_text;//For sold out events

if ( have_posts() ) :
// allow other stuff
do_action( ‘AHEE__espresso_events_table_template_template__before_loop’ );
?>

<?php if ($category_filter != ‘false’){ ?>
<p class=”category-filter”>
<label><?php echo __(‘Category Filter’, ‘event_espresso’); ?></label>
<select class=”” id=”ee_filter_cat”>
<option class=”ee_filter_show_all”><?php echo __(‘Show All’, ‘event_espresso’); ?></option>
<?php
$taxonomy = array(‘espresso_event_categories’);
$args = array(‘orderby’=>’name’,’hide_empty’=>true);
$ee_terms = get_terms($taxonomy, $args);

foreach($ee_terms as $term){
echo ‘<option class=”‘ . $term->slug . ‘”>’. $term->name . ‘</option>’;
}
?>
</select>
</p>
<?php } ?>

<?php if ($footable != ‘false’ && $table_search != ‘false’){ ?>
<p>
<?php echo __(‘Search:’, ‘event_espresso’); ?> <input id=”filter” type=”text”/>
</p>
<?php } ?>

<table id=”ee_filter_table” class=”espresso-table footable table” data-page-size=”<?php echo $table_pages; ?>” data-filter=”#filter”>
<thead class=”espresso-table-header-row”>
<tr>
<th class=”th-group”><?php _e(‘Event’,’event_espresso’); ?></th>
<th class=”th-group”><?php _e(‘Date’,’event_espresso’); ?></th>
<th class=”th-group”><?php _e(‘Day’,’event_espresso’); ?></th>
<th class=”th-group”><?php _e(‘Time’,’event_espresso’); ?></th>
<th class=”th-group”><?php _e(‘Venue’,’event_espresso’); ?></th>
<th class=”th-group” data-sort-ignore=”true”></th>
</tr>
</thead>
<?php if ($footable != ‘false’ && $table_paging != ‘false’){ ?>
<tfoot>
<tr>
<td colspan=”4″>
<div class=”pagination pagination-centered”></div>
</td>
</tr>
</tfoot>
<?php } ?>
<tbody>

<?php
// Start the Loop.
while ( have_posts() ) : the_post();
// Include the post TYPE-specific template for the content.
global $post;

//Debug
//d( $post );

//Get the category for this event
$event = EEH_Event_View::get_event();
if ( $event instanceof EE_Event ) {
if ( $event_categories = get_the_terms( $event->ID(), ‘espresso_event_categories’ )) {
// loop thru terms and create links
$category_slugs = ”;
foreach ( $event_categories as $term ) {
$category_slugs[] = $term->slug;
}
$category_slugs = implode(‘ ‘, $category_slugs);
} else {
// event has no terms
$category_slugs = ”;
}

}
//Create the event link
$external_url = $post->EE_Event->external_url();
$button_text = !empty($external_url) ? $alt_button_text : $reg_button_text;
$registration_url = !empty($external_url) ? $post->EE_Event->external_url() : $post->EE_Event->get_permalink();

//Create the register now button
$live_button = ‘ID.'” href=”‘.$registration_url.'”>’.$button_text.’‘;

if ( $event->is_sold_out() || $event->is_sold_out(TRUE ) ) {
$live_button = ‘ID.'” class=”a_register_link_sold_out” href=”‘.$registration_url.'”>’.$sold_out_button_text.’‘;
}

$datetimes = EEM_Datetime::instance()->get_datetimes_for_event_ordered_by_start_time( $post->ID, $show_expired, false, 1 );

$datetime = end( $datetimes );

//let’s use date_i18n on the correct offset for the timestamp. Note it seems like we’re doing a lot of
//unnecessary conversion but this is so it works with two different pardigmas in the EE core datetime
//system, without users having to worry about updating.

$startdate = date_i18n( $date_format);
?>
<tr class=”espresso-table-row <?php echo $category_slugs; ?>”>
<td class=”event_title event-<?php echo $post->ID; ?>”><?php echo $post->post_title; ?></td>

<td class=”start_date event-<?php echo $post->ID; ?>” data-value=”<?php echo $datetime->get_raw( ‘DTT_EVT_start’ ); ?>”><?php echo $startdate; ?></td>

<td class=”day_of_week event-<?php echo $post->ID; ?>”><?php espresso_event_date_range( ‘l’, ‘ ‘, ‘l’, ‘ ‘, $event->ID() ); ?></td>

<td class=”time event-<?php echo $post->ID; ?>”><?php espresso_event_date_range( ‘g:i a’, ‘ ‘, ‘ ‘, ‘ ‘, $event->ID() ); ?></td>

<td class=”venue_title event-<?php echo $post->ID; ?>”><?php espresso_venue_name( NULL, FALSE ); ?></td>

<td class=”td-group reg-col” nowrap=”nowrap”><?php echo $live_button; ?></td>
</tr>
<?php

endwhile;
echo ‘</table>’;
// allow moar other stuff
do_action( ‘AHEE__espresso_events_table_template_template__after_loop’ );

else :
// If no content, include the “No posts found” template.
espresso_get_template_part( ‘content’, ‘none’ );

endif;


Josh

  • Support Staff

March 9, 2016 at 7:54 am

Hi there,

So in your template where you have this:

$startdate = date_i18n( $date_format);

That’s broken.

You need to change it to something like this:

$startdate = date_i18n( $date_format, strtotime( $datetime->start_date_and_time('Y-m-d', 'H:i:s') ) );

In the future, please post code blocks that are longer than 10 lines to a pastebin or github gist and link here.


lee@safeswim.com

March 9, 2016 at 10:58 am

Thank you so much for the fast support! In the future I will post a link!

The support post ‘All the same dates appear in the table view when date/time columns are separated’ 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