Title: Bug in event-datetime.php template
Last modified: May 19, 2019

---

# Bug in event-datetime.php template

 *  Resolved [jjbte](https://wordpress.org/support/users/jjbte/)
 * (@jjbte)
 * [7 years ago](https://wordpress.org/support/topic/bug-in-event-datetime-php-template/)
 * I have found a bug in src/views/blocks/event-datetime.php.
 * In the template, a check is run to see if we should format the event date without
   the year. The result is true if the event is happening in the current year (line
   29):
 *     ```
       $use_yearless_format = apply_filters( 'tribe_events_event_block_datetime_use_yearless_format',
       	(
       		tribe_get_start_date( $event_id, false, 'Y' ) === date_i18n( 'Y' )
       		&& tribe_get_end_date( $event_id, false, 'Y' ) === date_i18n( 'Y' )
       	),
       	$event
       );
       ```
   
 * Then, on line 38, the tribe_get_date_format() function is called, using the value
   of $use_yearless_format obtained above.
    `$date_format = tribe_get_date_format(
   $use_yearless_format );`
 * If the event is happening in the current year, $use_yearless_format is true, 
   so a value of true is passed to the tribe_get_date_format() function.
 * The problem is that the tribe_get_date_format() function takes a value of $with_year.
   If $with_year is true, the year is included with the event date (common/src/functions/
   template-tags/general.php, line 162):
 *     ```
       function tribe_get_date_format( $with_year = false ) {
       		if ( $with_year ) {
       			$format = tribe_get_date_option( 'dateWithYearFormat', get_option( 'date_format' ) );
       		} else {
       			$format = tribe_get_date_option( 'dateWithoutYearFormat', 'F j' );
       		}
   
       		return apply_filters( 'tribe_date_format', $format );
       }
       ```
   
 * So we’re passing the opposite value we want when calling the tribe_get_date_format()
   function from event-datetime.php. As a result, the year is included for events
   happening in the current year, but not for events happening in other years.
 * Please address this issue in a future release.

The topic ‘Bug in event-datetime.php template’ is closed to new replies.

 * ![](https://ps.w.org/the-events-calendar/assets/icon-256x256.gif?rev=2516440)
 * [The Events Calendar](https://wordpress.org/plugins/the-events-calendar/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/the-events-calendar/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/the-events-calendar/)
 * [Active Topics](https://wordpress.org/support/plugin/the-events-calendar/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/the-events-calendar/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/the-events-calendar/reviews/)

## Tags

 * [bugs](https://wordpress.org/support/topic-tag/bugs/)
 * [date format](https://wordpress.org/support/topic-tag/date-format/)
 * [templates](https://wordpress.org/support/topic-tag/templates/)

 * 0 replies
 * 1 participant
 * Last reply from: [jjbte](https://wordpress.org/support/users/jjbte/)
 * Last activity: [7 years ago](https://wordpress.org/support/topic/bug-in-event-datetime-php-template/)
 * Status: resolved