Server IP : 23.254.227.96 / Your IP : 216.73.216.7 Web Server : Apache/2.4.62 (Unix) OpenSSL/1.1.1k System : Linux hwsrv-1277026.hostwindsdns.com 4.18.0-477.13.1.el8_8.x86_64 #1 SMP Tue May 30 14:53:41 EDT 2023 x86_64 User : viralblo ( 1001) PHP Version : 8.1.31 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /usr/local/cwpsrv/var/services/twig/doc/functions/ |
Upload File : |
``date`` ======== Converts an argument to a date to allow date comparison: .. code-block:: jinja {% if date(user.created_at) < date('-2days') %} {# do something #} {% endif %} The argument must be in one of PHP’s supported `date and time formats`_. You can pass a timezone as the second argument: .. code-block:: jinja {% if date(user.created_at) < date('-2days', 'Europe/Paris') %} {# do something #} {% endif %} If no argument is passed, the function returns the current date: .. code-block:: jinja {% if date(user.created_at) < date() %} {# always! #} {% endif %} .. note:: You can set the default timezone globally by calling ``setTimezone()`` on the ``core`` extension instance: .. code-block:: php $twig = new Twig_Environment($loader); $twig->getExtension('Twig_Extension_Core')->setTimezone('Europe/Paris'); Arguments --------- * ``date``: The date * ``timezone``: The timezone .. _`date and time formats`: http://php.net/manual/en/datetime.formats.php