For information shown for a node, I prefer the node.html.twig template, as it doesn't require to first check the page is rendered for a node. The node.html.twig template already has the following lines.
{% if display_submitted %}
<footer>
{{ author_picture }}
<div{{ author_attributes }}>
{% trans %}Submitted by {{ author_name }} on {{ date }}{% endtrans %}
{{ metadata }}
</div>
</footer>
{% endif %}
If I wanted to change the way the date is rendered, or which date is shown, without removing the other information shown in the template file, I would replace those lines with the following ones.
{% if display_submitted %}
<footer>
{{ author_picture }}
<div{{ author_attributes }}>
{% trans %}Last updated on {{ node.getChangedTime()|format_date('custom', 'D M d Y') }}{% endtrans %}
{{ metadata }}
</div>
</footer>
{% endif %}
For the Garland theme, which is now a contributed theme, the part to change is the following one.
{% if display_submitted %}
<span class="submitted">{{ date }} — {{ author_name }}</span>
{% endif %}
You can either replace those lines with the following lines, or the next ones, if you just want to change the date format.
{% if display_submitted %}
<span class="submitted">{% trans %}Last updated on {{ node.getChangedTime()|format_date('custom', 'D M d Y') }}{% endtrans %}</span>
{% endif %}
{% if display_submitted %}
<span class="submitted">{{ node.getChangedTime()|format_date('custom', 'D M d Y') }} — {{ author_name }}</span>
{% endif %}
As the documentation for the node.html.twig template says, not all the node properties and methods are accessible via node
; only the methods whose names start with get, has, or is are available, together a few common methods such as id
, label
, and bundle
.