mirror of
https://github.com/twigphp/Twig.git
synced 2026-08-30 12:06:56 +00:00
Fix docs
This commit is contained in:
@@ -52,13 +52,25 @@ Timezone
|
||||
--------
|
||||
|
||||
By default, the date is displayed by applying the default timezone (the one
|
||||
specified in php.ini), but you can override it by explicitly specifying a
|
||||
timezone:
|
||||
specified in php.ini or declared in Twig -- see below), but you can override
|
||||
it by explicitly specifying a timezone:
|
||||
|
||||
.. code-block:: twig
|
||||
|
||||
{{ datetime|format_datetime(locale='en', timezone='Pacific/Midway') }}
|
||||
|
||||
If the date is already a DateTime object, and if you want to keep its current
|
||||
timezone, pass ``false`` as the timezone value:
|
||||
|
||||
.. code-block:: twig
|
||||
|
||||
{{ datetime|format_datetime(locale='en', timezone=false) }}
|
||||
|
||||
The default timezone can also be set globally by calling ``setTimezone()``::
|
||||
|
||||
$twig = new \Twig\Environment($loader);
|
||||
$twig->getExtension(\Twig\Extension\CoreExtension::class)->setTimezone('Europe/Paris');
|
||||
|
||||
.. note::
|
||||
|
||||
The ``format_datetime`` filter is part of the ``IntlExtension`` which is not
|
||||
|
||||
Reference in New Issue
Block a user