Drupal 9: Calculate Published Time In Node Template

Add the following to a node template.

{% if node.bundle == 'article' and date(node.createdtime) < date('-2 year') %}
<div class="messages messages--warning" role="alert">
This article is over 2 years old.
{% endif %}

Add new comment

The content of this field is kept private and will not be shown publicly.
4 + 1 =
Solve this simple math problem and enter the result. E.g. for 1+3, enter 4.
This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.