I'm trying to make a comparison of two dates. When the date's the same i want the end date to not be displayed. For some reason the comparison doesn't work. The dates are being displayed as shortcodes.
Here's my code:
add_shortcode('tribe-start-date', 'tribe_start_date_shortcode');
function tribe_start_date_shortcode() {
global $post;
$start_date = tribe_get_start_date( $post->ID, false, 'd.m.Y' );
return $start_date;
}
add_shortcode('tribe-end-date', 'tribe_end_date_shortcode');
function tribe_end_date_shortcode() {
global $post;
$end_date = tribe_get_end_date( $post->ID, false, 'd.m.Y' );
if ($start_date != $end_date) {
return (' - ' . $end_date );
}
}
output:
01.10.2020 - 01.10.2020