I would like to create a conditional based on the value of a date field compared to today's date.

In English it would be: if Expiration Date is less than today's date set class to "expired"

Here is how I tried it in EE:

{if "{business_expire_date}" < "{current_time}"}class="expired"{/if}

Unfortunately, it doesn't work as desired. What is the correct way to write this?


1 Answer 1


The dates need to be formatted properly first to compare them. Something like this:

{if {business_expire_date format="%U"} < {current_time format="%U"}}class="expired"{/if}

You may need to change the comparison operator < to get desired results.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.