• Resolved jbx

    (@jbx)


    I am using the the #_EVENTDATES placeholder in my template to display single or multi-day event dates respectively.
    Is there any way to detect that an event’s month and year is the same and eliminate them?

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

    If it spans over the end of a month however I would ideally get: 25 NOV – 03 DEC 2012

    Is there any way I can go about this?

    https://www.ads-software.com/extend/plugins/events-manager/

Viewing 3 replies - 1 through 3 (of 3 total)
  • agelonwl

    (@angelonwl)

    Thread Starter jbx

    (@jbx)

    Thanks for that!

    This is the code I actually used, in case anyone else is looking for it. It checks if the year is the same before omitting it, and then checks if the month is the same before omitting it. If the day is also the same it does nothing because EM already works perfectly in that case.

    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;
    }
    Plugin Author Marcus (aka @msykes)

    (@netweblogic)

    thx, the first snippet I’ve added to the upcoming snippets section we’re making ??

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘How to remove redundant Month/Year in multi-day events’ is closed to new replies.