mirror of
https://github.com/twigphp/Twig.git
synced 2026-09-13 02:46:29 +00:00
added doc and fixed CS for previous merge
This commit is contained in:
@@ -1115,6 +1115,9 @@ List of built-in Filters
|
||||
``date``
|
||||
~~~~~~~~
|
||||
|
||||
.. versionadded:: 1.1
|
||||
The timezone support has been added in Twig 1.1.
|
||||
|
||||
The ``date`` filter is able to format a date to a given format:
|
||||
|
||||
.. code-block:: jinja
|
||||
@@ -1135,6 +1138,10 @@ To escape words and characters in the date format use ``\\`` in front of each ch
|
||||
|
||||
{{ post.published_at|date("F jS \\a\\t g:ia") }}
|
||||
|
||||
You can also specify a timezone:
|
||||
|
||||
{{ post.published_at|date("m/d/Y", "Europe/Paris") }}
|
||||
|
||||
``format``
|
||||
~~~~~~~~~~
|
||||
|
||||
|
||||
@@ -201,7 +201,7 @@ class Twig_Extension_Core extends Twig_Extension
|
||||
}
|
||||
}
|
||||
|
||||
function twig_date_format_filter($date, $format = 'F j, Y H:i', $timezone = NULL)
|
||||
function twig_date_format_filter($date, $format = 'F j, Y H:i', $timezone = null)
|
||||
{
|
||||
if (!$date instanceof DateTime) {
|
||||
if (ctype_digit((string) $date)) {
|
||||
@@ -212,7 +212,7 @@ function twig_date_format_filter($date, $format = 'F j, Y H:i', $timezone = NULL
|
||||
}
|
||||
}
|
||||
|
||||
if ($timezone !== NULL) {
|
||||
if (null !== $timezone) {
|
||||
if (!$timezone instanceof DateTimeZone) {
|
||||
$timezone = new DateTimeZone($timezone);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user