• Resolved terry777

    (@terry777)


    I have had a request that the current year events show the year rather than month and day only. Right now, only events in the future year display the year.

    e.g.
    2019 event:
    <span class=”tribe-event-date-start”>August 10 @ 8:00 am</span>
    2020 event:
    <span class=”tribe-event-date-start”>January 8, 2020 @ 8:00 am</span>

    I don’t see a setting for this. Is it possible to get it to display the year for the current year?
    I’m hoping it can be done with CSS, rather than by editing a php file, but I thought I’d ask.

    Thanks

    The page I need help with: [log in to see the link]

Viewing 3 replies - 1 through 3 (of 3 total)
  • This is a major issue and flaw in the Events plugin. Not displaying the year prevents Google from correctly identifying the Event and displaying it on their Knowledge graph.

    This can be seen as a flaw by utilizing Google’s Data Highlighter and trying to “teach” it how to process event data on your site. It states that if you cannot highlight the “Year” that the event is invalid.

    Plugin Support Jaime

    (@jaimemarchwinski)

    Hi @terry777 and @lordneeko,

    You can alter the event start date formatting using some PHP.

    Here is an example:
    echo tribe_get_start_date( $event_id, true, 'm-d-Y h:i:s' );

    ? The first argument for tribe_get_start_date is the event ID of the event whose start date you’re getting
    ? The second argument is simply true or false: true if you want the “time” to show in addition to date, false if not. It defaults to true.
    ? The third argument is the PHP-style date format string which will be the format of the generated date.

    I hope that helps!

    Thanks,
    Jaime

    Hi.

    Changing this behaviour seems impossible since it is hard coded in the plugin.

    In the file wp-content\plugins\the-events-calendar\common\src\functions\template-tags\date.php there is the function tribe_format_date() in which I can read :

    —————————–
    // only show the year in the date if it’s not in the current year
    $with_year = $date_year == $cur_year ? false : true;

    if ( $display_time ) {
    $format = tribe_get_datetime_format( $with_year );
    } else {
    $format = tribe_get_date_format( $with_year );
    }
    —————————–

    A filter at this point would be welcome.
    Something like this :

    $with_year = apply_filters( ‘tribe_remove_year_for_current_year’, $with_year );

    Thanks
    Gilles

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘event start date format – missing year in current year’ is closed to new replies.