mirror of
https://github.com/twigphp/Twig.git
synced 2026-09-12 02:16:41 +00:00
updated the CHANGELOG and documentation for previous merge
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
* 1.7.0-DEV
|
||||
|
||||
* added a way to set the default global timezone for dates
|
||||
* fixed the slice filter on strings when the length is not specified
|
||||
* fixed the creation of the cache directory in case of a race condition
|
||||
|
||||
|
||||
+13
-3
@@ -7,6 +7,9 @@
|
||||
.. versionadded:: 1.5
|
||||
The default date format support has been added in Twig 1.5.
|
||||
|
||||
.. versionadded:: 1.7
|
||||
The default timezone support has been added in Twig 1.7.
|
||||
|
||||
The ``date`` filter formats a date to a given format:
|
||||
|
||||
.. code-block:: jinja
|
||||
@@ -34,15 +37,22 @@ 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 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:
|
||||
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', '%d days');
|
||||
|
||||
The default timezone can also be set globally by calling ``setTimezone()``:
|
||||
|
||||
.. code-block:: php
|
||||
|
||||
$twig = new Twig_Environment($loader);
|
||||
$twig->getExtension('core')->setTimezone('Europe/Paris');
|
||||
|
||||
.. _`date`: http://www.php.net/date
|
||||
.. _`DateTime`: http://www.php.net/DateTime
|
||||
.. _`DateInterval`: http://www.php.net/DateInterval
|
||||
|
||||
@@ -4,6 +4,9 @@
|
||||
.. versionadded:: 1.6
|
||||
The date function has been added in Twig 1.6.
|
||||
|
||||
.. versionadded:: 1.7
|
||||
The default timezone support has been added in Twig 1.7.
|
||||
|
||||
Converts an argument to a date to allow date comparison:
|
||||
|
||||
.. code-block:: jinja
|
||||
@@ -30,4 +33,14 @@ If no argument is passed, the function returns the current date:
|
||||
{# always! #}
|
||||
{% endif %}
|
||||
|
||||
.. note::
|
||||
|
||||
You can set the default timezone globally by calling ``setTimezone()`` on
|
||||
the ``core`` extension instance:
|
||||
|
||||
.. code-block:: php
|
||||
|
||||
$twig = new Twig_Environment($loader);
|
||||
$twig->getExtension('core')->setTimezone('Europe/Paris');
|
||||
|
||||
.. _`date`: http://www.php.net/date
|
||||
|
||||
Reference in New Issue
Block a user