Website Logo
  • Features
  • AI ✦
  • Pricing
  • Add-Ons
  • Support
    • Documentation
    • Tutorials
    • FAQ
    • Troubleshooting Tips
    • Pro Support Forums
    • Community Forums
  • Blog
  • Contact
Go Pro Demo

Remove Month/Year in #_EVENTDATES if date range is same Month/Year

  1. Home
  2. Snippets

Remove Month/Year in #_EVENTDATES if date range is same Month/Year

I am getting this: 03 DEC 2012 – 09 DEC 2012

While ideally I would get this: 03 – 09 DEC 2012

add_filter('em_event_output_placeholder','my_em_placeholder_mod',1,3);
function my_em_placeholder_mod($replace, $EM_Event, $result)
{
	if ( $result == '#_EVENTDATES' )
	{
		$day_start = date_i18n('d', $EM_Event->start);
		$day_end = date_i18n('d', $EM_Event->end);

		if ($day_start != $day_end)
		{
			$date_format_start = 'd';

			$year_start = date_i18n('Y', $EM_Event->start);
			$year_end = date_i18n('Y', $EM_Event->end);

			if ($year_start != $year_end)
			{
				$date_format_start .= ' M Y';
			}
			else
			{
				$month_start = date_i18n('M', $EM_Event->start);
				$month_end = date_i18n('M', $EM_Event->end);

				if ($month_start != $month_end)
				{
					$date_format_start .= ' M';
				}
			}

			$replace = date_i18n($date_format_start, $EM_Event->start). ' - ' . date_i18n('d M Y', $EM_Event->end);
		}
	}
	return $replace;
}

Originally submitted here.

Recent News

  • IMPORTANT Security Update – A ‘Mythosical’ Fable
  • Plugin Updating – Recommendations
  • Mobile App Now In App Store!
  • Events Manager 7.3.7 and Pro 3.8.5
  • Events Manager 7.3.6, Pro 3.8.4, Square, Xero, WooCommerce, PayPal and more!
Events Manager for Wordpress

Ready to take your events to the next level?

Get Started, Go Pro!
Pro Member Links
  • Pro Support Forums
  • Your Account
Events Manager Support
  • Community Forums
  • Documentation
  • Download Events Manager
  • Troubleshooting Help
Other Useful Links
  • Contact Us
  • Privacy Policy
  • Terms and Conditions
Recent Blog Posts
  • IMPORTANT Security Update – A ‘Mythosical’ Fable
  • Plugin Updating – Recommendations
  • Mobile App Now In App Store!
  • Events Manager 7.3.7 and Pro 3.8.5
  • Events Manager 7.3.6, Pro 3.8.4, Square, Xero, WooCommerce, PayPal and more!

More blog posts ...

About This Plugin

Events Manager is a plugin for WordPress which enables you to publish event, locations and calendars as well as accepting bookings for these events. Events Manager started as a labor of love and has been available for free since 2008 on the wordpress.org repo, and in 2011 we released a Pro add-on which is now funding further development.

More on our history...

Copyright © 2026 | A Pixelite Production