Skip to content

Commit

Permalink
added doc and fixed CS for previous merge
Browse files Browse the repository at this point in the history
  • Loading branch information
fabpot committed Jun 24, 2011
1 parent bbf55fe commit 8a5f6bf
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
7 changes: 7 additions & 0 deletions doc/templates.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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``
~~~~~~~~~~

Expand Down
4 changes: 2 additions & 2 deletions lib/Twig/Extension/Core.php
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ public function getName()
}
}

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)) {
Expand All @@ -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);
}
Expand Down

0 comments on commit 8a5f6bf

Please sign in to comment.