<p>To get the current date and time in Twig use the string <a href="http://twig.sensiolabs.org/doc/filters/date.html" rel="nofollow noreferrer"><code>&quot;now&quot;</code></a> and filter it with the <a href="http://twig.sensiolabs.org/doc/filters/date.html" rel="nofollow noreferrer"><code>date()</code></a> filter to return it in the format you need (see the <a href="https://www.php.net/manual/en/function.date.php" rel="nofollow noreferrer">list for supported parameters</a>).</p>
<p>Then do the <a href="http://twig.sensiolabs.org/doc/tags/if.html" rel="nofollow noreferrer"><code>if</code> / <code>elseif</code></a> conditionals similar to how you'd do it in PHP. Another option would be to use the Craft specific <a href="http://buildwithcraft.com/docs/templating/switch" rel="nofollow noreferrer"><code>switch</code></a> tag.</p>
<pre class="lang-none prettyprint-override"><code>{% switch &quot;now&quot; | date(&quot;l&quot;) %}

    {% case &quot;Monday&quot; %}
        {# Do Monday stuff #}

    {% case &quot;Tuesday&quot; %}
        {# Do Tuesday stuff #}

    {% case &quot;Wednesday&quot; %}
        {# Do Wednesday stuff #}

    {# etc. #}

{% endswitch %}
</code></pre>

CC BY-SA 3.0
2014-08-18T16:47:32.017Z
2014-08-18T16:56:40.777Z
2023-11-17T19:30:35.897Z
Lindsey D
<p>I can do it in PHP, but I'm having trouble converting it to twig. </p>

<p>Here's the PHP:</p>

<pre class="lang-php prettyprint-override"><code>$day = date("l");
date_default_timezone_set('America/Chicago');



if ($day == "Saturday")
{
    echo "&lt;p&gt;&lt;b&gt;SATURDAY SPECIALS&lt;/b&gt;&lt;/p&gt;";
    echo "&lt;/div&gt;&lt;div class=\"mod1\"&gt;";
    echo "&lt;p&gt;FOOD&lt;/p&gt;";
    echo "&lt;h3&gt;Half priced desserts&lt;/h3&gt;";
    echo "&lt;p&gt;DRINK&lt;/p&gt;";
    echo "&lt;h3&gt;$1 off Seasonal Pints&lt;/h3&gt;";

}
elseif ($day == "Sunday")
{
    echo "&lt;p&gt;&lt;b&gt;GAMEDAY SPECIALS&lt;/b&gt;&lt;/p&gt;";
    echo "&lt;/div&gt;&lt;div class=\"mod1\"&gt;";
    echo "&lt;p&gt;FOOD&lt;/p&gt;";
    echo "&lt;h3&gt;One Free Kids Meal w/ each Adult Meal&lt;/h3&gt;";
    echo "&lt;p&gt;DRINK&lt;/p&gt;";
    echo "&lt;h3&gt;$3 on ALL Bottled Beers&lt;/h3&gt;";    }
elseif ($day == "Monday")
{
    echo "&lt;p&gt;&lt;b&gt;MONDAY SPECIALS&lt;/b&gt;&lt;/p&gt;";
    echo "&lt;/div&gt;&lt;div class=\"mod1\"&gt;";
    echo "&lt;p&gt;FOOD&lt;/p&gt;";
    echo "&lt;h3&gt;$1 Tenders &lt;br /&gt;(5 piece min.)&lt;/h3&gt;";
    echo "&lt;p&gt;DRINK&lt;/p&gt;";
    echo "&lt;h3&gt;$2 Lonestar Pints&lt;/h3&gt;";  }
elseif ($day == "Tuesday")
{
    echo "&lt;p&gt;&lt;b&gt;TUESDAY SPECIALS&lt;/b&gt;&lt;/p&gt;";
    echo "&lt;/div&gt;&lt;div class=\"mod1\"&gt;";
    echo "&lt;p&gt;FOOD&lt;/p&gt;";
    echo "&lt;h3&gt;$.50 Boneless Wings &lt;br /&gt; (10 piece min.)&lt;/h3&gt;";
    echo "&lt;p&gt;DRINK&lt;/p&gt;";
    echo "&lt;h3&gt;$4 Margaritas&lt;/h3&gt;";  }
elseif ($day == "Wednesday")
{
    echo "&lt;p&gt;&lt;b&gt;WEDNESDAY SPECIALS&lt;/b&gt;&lt;/p&gt;";
    echo "&lt;/div&gt;&lt;div class=\"mod1\"&gt;";
    echo "&lt;p&gt;FOOD&lt;/p&gt;";
    echo "&lt;h3&gt;Half price APPs!&lt;/h3&gt;";
    echo "&lt;p&gt;DRINK&lt;/p&gt;";
    echo "&lt;h3&gt;$3 shots of Jameson &amp; Jager&lt;/h3&gt;";
}
elseif ($day == "Thursday")
{
    echo "&lt;p&gt;&lt;b&gt;THURSDAY SPECIALS&lt;/b&gt;&lt;/p&gt;";
    echo "&lt;/div&gt;&lt;div class=\"mod1\"&gt;";
    echo "&lt;p&gt;FOOD&lt;/p&gt;";
    echo "&lt;h3&gt;2 for $10 Wingzup Burgers&lt;/h3&gt;";
    echo "&lt;p&gt;DRINK&lt;/p&gt;";
    echo "&lt;h3&gt;$3 Draft Beers all day&lt;/h3&gt;";
}
else
{
    echo "&lt;p&gt;&lt;b&gt;FRIDAY SPECIALS&lt;/b&gt;&lt;/p&gt;";
    echo "&lt;/div&gt;&lt;div class=\"mod1\"&gt;";
    echo "&lt;p&gt;FOOD&lt;/p&gt;";
    echo "&lt;h3&gt;$2 Chili Pies&lt;/h3&gt;";
    echo "&lt;p&gt;DRINK&lt;/p&gt;";
    echo "&lt;h3&gt;$10 Pitchers (Bud Lt./Ziegenbock/Lone Star)&lt;/h3&gt;";
}
</code></pre>

CC BY-SA 3.0
2014-08-18T17:01:14.303Z
You not gonna hardcode the daily menus into your template, Alex?
carlcs
<templating><datetime>
How do I make display a specific post based on what the day of the week it is?
# How do I make display a specific post based on what the day of the week it is?

(Asked by: username_0 on 2014-08-18)

I can do it in PHP, but I'm having trouble converting it to twig. 
Here's the PHP:
$day = date("l");
date_default_timezone_set('America/Chicago');



if ($day == "Saturday")
{
    echo "SATURDAY SPECIALS";
    echo "";
    echo "FOOD";
    echo "Half priced desserts";
    echo "DRINK";
    echo "$1 off Seasonal Pints";

}
elseif ($day == "Sunday")
{
    echo "GAMEDAY SPECIALS";
    echo "";
    echo "FOOD";
    echo "One Free Kids Meal w/ each Adult Meal";
    echo "DRINK";
    echo "$3 on ALL Bottled Beers";    }
elseif ($day == "Monday")
{
    echo "MONDAY SPECIALS";
    echo "";
    echo "FOOD";
    echo "$1 Tenders (5 piece min.)";
    echo "DRINK";
    echo "$2 Lonestar Pints";  }
elseif ($day == "Tuesday")
{
    echo "TUESDAY SPECIALS";
    echo "";
    echo "FOOD";
    echo "$.50 Boneless Wings  (10 piece min.)";
    echo "DRINK";
    echo "$4 Margaritas";  }
elseif ($day == "Wednesday")
{
    echo "WEDNESDAY SPECIALS";
    echo "";
    echo "FOOD";
    echo "Half price APPs!";
    echo "DRINK";
    echo "$3 shots of Jameson & Jager";
}
elseif ($day == "Thursday")
{
    echo "THURSDAY SPECIALS";
    echo "";
    echo "FOOD";
    echo "2 for $10 Wingzup Burgers";
    echo "DRINK";
    echo "$3 Draft Beers all day";
}
else
{
    echo "FRIDAY SPECIALS";
    echo "";
    echo "FOOD";
    echo "$2 Chili Pies";
    echo "DRINK";
    echo "$10 Pitchers (Bud Lt./Ziegenbock/Lone Star)";
}

**Tags:** templating, datetime
> **Comments:**
> **username_1**: You not gonna hardcode the daily menus into your template, Alex?  

---

## 1 answers

### Answer by username_2 on 2014-08-18. Score: 6 | Accepted answer

To get the current date and time in Twig use the string "now" and filter it with the date() filter to return it in the format you need (see the list for supported parameters).
Then do the if / elseif conditionals similar to how you'd do it in PHP. Another option would be to use the Craft specific switch tag.
{% switch "now" | date("l") %}

    {% case "Monday" %}
        {# Do Monday stuff #}

    {% case "Tuesday" %}
        {# Do Tuesday stuff #}

    {% case "Wednesday" %}
        {# Do Wednesday stuff #}

    {# etc. #}

{% endswitch %}


---

