Second IF statement is getting ignored

50 Views Asked by At

Why is the variable currentday not outputing: 2 Condition? Somehow it is not entering the second IF statement.

        {% set currentday = '10.04.2022'|date('d.m.Y') %}

        <h1>Today: {{ currentday }}</h1>

        {% if currentday >= '01.01.2022' and currentday <= '31.03.2022' %}
            <h1>1 Condition </h1>
        {% elseif currentday >= '01.04.2022' and currentday <= '30.06.2022' %}
            <h1>2 Condition </h1>
        {% elseif currentday >= '01.07.2022' and currentday <= '30.09.2022' %}
            <h1>3 Condition </h1>
        {% elseif currentday >= '01.10.2022' and currentday <= '31.12.2022' %}
            <h1>4 Condition </h1>
        {% endif %}
1

There are 1 best solutions below

0
On

If the date is formatted in this way in the variable and if/else then it works like a charm:

{% set currentday = '2022-08-10'|date('Y-m-d') %}