5 The date function has been added in Twig 1.6.
7 .. versionadded:: 1.6.1
8 The default timezone support has been added in Twig 1.6.1.
10 Converts an argument to a date to allow date comparison:
14 {% if date(user.created_at) < date('-2days') %}
18 The argument must be in a format supported by the `date`_ function.
20 You can pass a timezone as the second argument:
24 {% if date(user.created_at) < date('-2days', 'Europe/Paris') %}
28 If no argument is passed, the function returns the current date:
32 {% if date(user.created_at) < date() %}
38 You can set the default timezone globally by calling ``setTimezone()`` on
39 the ``core`` extension instance:
43 $twig = new Twig_Environment($loader);
44 $twig->getExtension('core')->setTimezone('Europe/Paris');
50 * ``timezone``: The timezone
52 .. _`date`: http://www.php.net/date