Forum

Thread tagged as: Question, Events

Using perch:if

I'm trying to compare the just "day" of date of an eventDate with the "day" of eventDate_End, and then only output a section of my template if that eventDate_End "day" is greater than the original eventDate.

Not sure best way or even if possible, is there a perch:if attribute that would work for this?

<perch:if id="eventDateTime_End" match="gt" value="{eventDateTime}" format="j">
                       <div class="eventDetail-group">
                           <div class="eventDetail-subtitle">Date(s):</div>
                           <perch:events id="eventDateTime" type="date" format="F j" />-<perch:events id="eventDateTime_End" type="date" format="jS, Y" />
                       </div>
                       <div class="eventDetail-group">
                           <div class="eventDetail-subtitle">Time:</div>
                           <perch:events id="eventDateTime" type="date" format="g:i a" /> - <perch:events id="eventDateTime_End" type="date" format="g:i a" />
                       </div>
                   <perch:else />
                      <div class="eventDetail-group">
                          <div class="eventDetail-subtitle">Date:</div>
                          <perch:events id="eventDateTime" type="date" format="F j, Y" />
                      </div>
                      <div class="eventDetail-group">
                          <div class="eventDetail-subtitle">Time:</div>
                          <perch:events id="eventDateTime" type="date" format="g:i a" />
                      </div>
                  </perch:if>
                      <div class="eventDetail-group">
                          <div class="eventDetail-subtitle">Categories:</div>
                          <perch:events id="category_names" encode="false" />
                      </div>
Seth Girardin

Seth Girardin 0 points

  • 5 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

That won't work to use just the day. If an event went from 31st to 1st, the end date would be less than the start.

Compare the whole day with format="Y-m-d"

Works perfect. Thanks Drew. Makes sense.