{{ post.published_at|date("m/d/Y") }}
-The ``date`` filter accepts any date format supported by `date`_ and
-`DateTime`_ instances. For instance, to display the current date, filter the
-word "now":
+The ``date`` filter accepts strings (it must be in a format supported by the
+`date`_ function), `DateTime`_ instances, or `DateInterval`_ instances. For
+instance, to display the current date, filter the word "now":
.. code-block:: jinja
{{ post.published_at|date("m/d/Y", "Europe/Paris") }}
If no format is provided, Twig will use the default one: ``F j, Y H:i``. This
-default can be easily changed:
+default can be easily changed by calling the `setDateFormat()` method on the
+`core` extension instance. The first argument is the default format for dates
+and the second one is the default format for date intervals:
.. code-block:: php
$twig = new Twig_Environment($loader);
- $twig->getExtension('core')->setDateFormat('d/m/Y');
+ $twig->getExtension('core')->setDateFormat('d/m/Y', '%d days');
-.. _`date`: http://www.php.net/date
-.. _`DateTime`: http://www.php.net/manual/en/datetime.construct.php
+.. _`date`: http://www.php.net/date
+.. _`DateTime`: http://www.php.net/DateTime
+.. _`DateInterval`: http://www.php.net/DateInterval