Trying to render a custom date format with Twig I'm in the process of porting one of my contrib themes to Drupal 8. For custom date formats on nodes, I have something like this in a node_preprocess function in the theme's template.php file in the Drupal 7 version:

$vars['thedate'] = format_date($node-&gt;created, "custom", "j");
$vars['themonth'] = format_date($node-&gt;created, "custom", "M");
$vars['theyear'] = format_date($node-&gt;created, "custom", "Y");


I render it with the following code.

  &lt;?php print $thedate; ?&gt; / &lt;?php print $themonth; ?&gt; / &lt;?php print $theyear; ?&gt;


In my Drupal 8 port, I've tried a similar approach in the theme's .theme file and then try to render them in node.html.twig as {{{ thedate }} / {{ themonth }} / {{ theyear }}}, but I'm getting a nasty error.


  Twig_Error_Runtime: An exception has been thrown during the rendering of a template ("The timestamp must be numeric.") in themes/mytheme/templates/page.html.twig 
          at line 210. in Twig_Template->displayWithErrorHandling() 
          (line 279 of /site/core/vendor/twig/twig/lib/Twig/Template.php).


I looked to Twig date formats, and it seems you should simply attach a variable, such as {{ display_submitted |date("m/d/Y") }}. I tried that without a preprocess function but what outputs is 12/31/1969, which is not the date the node was created so I'm a bit lost here.
Here is an approach that uses just Twig (no preprocess functions needed):

&lt;p&gt;{{ node.createdtime | date("d F Y") }}&lt;/p&gt;