Support » Plugins and Hacks » AM Events » [Resolved] Remove end date if it's same as start date

[Resolved] Remove end date if it's same as start date

  • Firstly, let me state that this plugin is great. Nice and clean. However, I’m trying to figure out how to remove the start or end date if the event is only a single day. For example, I would prefer it to output July 4 instead of July 4 – July 4. I was combing through the code, but I’m pretty lost when it comes to PHP.

    Any ideas on how to accomplish this?

    I still want events that span more than a day to output the start and end dates too.

    If the event calendar could look like this, that would be great:
    July 4
    August 3 – August 10
    September 1 – September 2


Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Atte Moisio



    Sorry for taking so long to answer. Anyway, if you are displaying the events in a page template, it is as easy as using a conditional statement to check if the dates are equal and displaying based on that.

    However, if you are using the widget, then it’s not so easy. I’ll probably be adding some kind of conditional tags for the widget in the future. Meanwhile, if you want, you could do the following:

    in widget-upcoming-events.php in function process_shortcode( $m ) replace:

    case 'end-date':
      $enddate = am_get_the_enddate();
      $format = $format === '' ? "m/d/Y H:i" : $format;
      return $m[1] . date_i18n( $format, strtotime($enddate) ) . $m[6];


    case 'end-date':
      $enddate = am_get_the_enddate();
      $format = $format === '' ? "m/d/Y H:i" : $format;
      if (am_get_the_startdate() !== am_get_the_enddate()) {
        return $m[1] . date_i18n( $format, strtotime($enddate) ) . $m[6];

    Plugin Author Atte Moisio


    Hey again,

    You can ignore the instructions in the previous post, I’ve just updated the plugin and included the conditional tags 🙂

    Example of displaying end date only if it not the same as the startdate:

    [start-date format='D d.m.Y H:s']
    [if cond='startdate-not-enddate']
     - [end-date format='D d.m.Y H:s']
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘[Resolved] Remove end date if it's same as start date’ is closed to new replies.
Skip to toolbar