Reputation: 3690
I want to be able to display the text "OK" if a date is less than 2 years old, and if it's older than 2 years old I want to display "Over 2 years old". How can I do this using Twig?
Upvotes: 0
Views: 694
Reputation: 3190
this problem is explained on twig documentation about date function
{% if date(mydate) > date('-2 years') %}
OK
{% else %}
Less than 2 years old
{% endif %}
Upvotes: 3