1

Hi I'm trying to template out a simple conditional that shows content if the date set in a date field is greater or equal to today, and I can't seem to get the syntax quite right.

I have tried this:

{% if entry.promoEndDate|date ('>= ' ~ now) %}
    <p class="price--notes">Price valid until {{ entry.promoEndDate | date('d M Y') }}</p>
{% endif %}

And this:

{% if entry.promoEndDate | date >= now | date %}
    <p class="price--notes">Price valid until {{ entry.promoEndDate | date('d M Y') }}</p>
{% endif %}

Both don't yield the result I'm looking for. Probably missing something really simple here but looked at it too long now.

Thanks in advance

since1976
  • 249
  • 2
  • 6

1 Answers1

1

You should be able to just compare the two dates directly.

{% if entry.promoEndDate >= now %}
    <p class="price--notes">Price valid until {{ entry.promoEndDate|date('d M Y') }}</p>
{% endif %}
Douglas McDonald
  • 13,457
  • 24
  • 57