Set format of date field in twig using drupal 8

Twig comes with quite some handy functionalities. Date formatting is an example. In this snippet an example of how to show the created date in a drupal 8 time format. 

{% set date = node.created.value|date('U')|format_date('short') %}
{{ date }}

You could also do just the following:

{% set date = node.created.value %}
{{ date|date('M d') }}

 

 

Saved you some valuable time?

Buy me a drink 🍺 to keep me motivated to create free content like this!