From: Fabien Potencier Date: Fri, 30 Dec 2011 08:21:01 +0000 (+0100) Subject: updated doc for the date filter X-Git-Url: http://git.silmor.de/gitweb/?a=commitdiff_plain;h=f64d976182a8babe2cec4239f7bde8d629ef8db8;p=konrad%2Ftwig.git updated doc for the date filter --- diff --git a/doc/filters/date.rst b/doc/filters/date.rst index 897645e..60e94e2 100644 --- a/doc/filters/date.rst +++ b/doc/filters/date.rst @@ -13,9 +13,9 @@ The ``date`` filter formats a date to a given format: {{ 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 @@ -34,12 +34,15 @@ You can also specify a timezone: {{ 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