This question already has an answer here:

Try this code (at node.html.twig, Drupal 8.0.0-rc3):

{% set date = node.created|format_date('long') %}

And next:

{{ dump(date) }}

Return error:

Exception: The timestamp must be numeric. in Drupal\Component\Datetime\DateTimePlus::createFromTimestamp() (line 165 of core/lib/Drupal/Component/Datetime/DateTimePlus.php).

Drupal\Core\Datetime\DateFormatter->format(Object, 'long')

marked as duplicate by DRUPWAY, kiamlaluno Jun 14 '17 at 11:37

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.


you are not using the actual timestamp. Here's what you should do:

{% set date = node.createdtime|format_date('long') %}

See? You only need to replace created with createdtime. Hope this helps.

  • Thx, this work. – Platon Nov 12 '15 at 11:36
  • And what variables, such as createdtime, from node? If I try {{ dump(node) }} — request is WSOD.. – Platon Nov 12 '15 at 11:39
  • Use Kint. It's a sub module of the devel module. – Cottser Nov 12 '15 at 12:01
  • createdtime is a twig style shortcut for the getCreatedTime() method. node.created is a FIeldItemList object, you can get the same value by accessing the value field property with node.created.value1format... Only base fields have methods, configurable fields need to be access like above. – Berdir Nov 12 '15 at 21:36
  • {% set date = node.createdtime|format_date('long') %} did not work for me. I had to use: {% set date = node.createdtime|date('long') %} – Ben Apr 18 '17 at 11:04

Try in this way.

{% set date = node.created %}
{{ set date|date("m/d/Y") }}
  • Refer here to know more about filter date in TWIG.
  • Refer here to know more about date formats in php.

Hope this will help you.

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