``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
{{ 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``
~~~~~~~~~~
}
}
-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)) {
}
}
- if ($timezone !== NULL) {
+ if (null !== $timezone) {
if (!$timezone instanceof DateTimeZone) {
$timezone = new DateTimeZone($timezone);
}