Search code examples
twigconditional-statementsime

How to get Time in twig?


enter image description here

Good Morning .. I want t add a condition like {% if time > 18 H and time < 22 H %} Payer {%endif%}

I don't know how can i get the time in twig ??


Solution

  • You can do it like this:

    {% if 'now'|date("H") > 18 and 'now'|date("H") < 22 %}
    

    If you're talking about current time.