<p>I guess you could do something like this. I'm assuming the events have <code>eventStart</code> and <code>eventEnd</code> date variables, and I'm here comparing the dates with the built in <code>now</code> variable on the format year-month-hour-minute:</p>

<pre><code>{# When eventStart is bigger than "now", the event is in the future #}
{% if event.eventStart|date('YmdHi') &gt; now|date('YmdHi') %}
  I will attend this event!

{# When eventStart is in the past, and eventEnd is in the future, the event is ongoing #}
{% elseif event.eventStart|date('YmdHi') &lt;= now|date('YmdHi') and event.eventEnd|date('YmdHi') &gt; now|date('YmdHi') %}
  I am at this event RIGHT NOW!

{# When none of the above, the event is in the past #}
{% else %}
  I was at this event
{% endif %}
</code></pre>

<p>Depending on your use, you could build on this to create a variable for "past/present/future" or similiar. To be even more sure on your validation, the last <code>endif</code> could also specifically test that the <code>endDate</code> is in the past, instead of just being a catch-all <code>else</code>.</p>

CC BY-SA 3.0
2017-07-29T16:31:18.370Z
2017-07-29T16:31:18.370Z
KSP
<p>I have set up a structure that allows me to display events with some information.  I'd like to know if there's a way that I can set a date that will automatically change certain  it's a text from being future tense to be in present tense during the event and past tense after the event i.e.  I'll be, I am, I was.</p>

<p>Thanks to everyone in advance! </p>

<templating>
Text that is conditional on date
# Text that is conditional on date

(Asked by: username_0 on 2017-07-29)

I have set up a structure that allows me to display events with some information. I'd like to know if there's a way that I can set a date that will automatically change certain it's a text from being future tense to be in present tense during the event and past tense after the event i.e. I'll be, I am, I was.

Thanks to everyone in advance!

**Tags:** templating


---

## 1 answers

### Answer by username_1 on 2017-07-29. Score: 2 | Accepted answer

I guess you could do something like this. I'm assuming the events have eventStart and eventEnd date variables, and I'm here comparing the dates with the built in now variable on the format year-month-hour-minute:
{# When eventStart is bigger than "now", the event is in the future #}
{% if event.eventStart|date('YmdHi') > now|date('YmdHi') %}
  I will attend this event!

{# When eventStart is in the past, and eventEnd is in the future, the event is ongoing #}
{% elseif event.eventStart|date('YmdHi') <= now|date('YmdHi') and event.eventEnd|date('YmdHi') > now|date('YmdHi') %}
  I am at this event RIGHT NOW!

{# When none of the above, the event is in the past #}
{% else %}
  I was at this event
{% endif %}

Depending on your use, you could build on this to create a variable for "past/present/future" or similiar. To be even more sure on your validation, the last endif could also specifically test that the endDate is in the past, instead of just being a catch-all else.


---

