Answers.Body: <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>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-08-18T16:47:32.017Z
Answers.LastActivityDate: 2014-08-18T16:56:40.777Z
Answers.LastEditDate: 2023-11-17T19:30:35.897Z
Answers.UserDisplayName: Lindsey D
Body: <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>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2014-08-18T17:01:14.303Z
Comments.Text: You not gonna hardcode the daily menus into your template, Alex?
Comments.UserDisplayName: carlcs
Tags: <templating><datetime>
Title: How do I make display a specific post based on what the day of the week it is?
ThreadText: # 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:
  
  ```php
  $day = date("l");
  date_default_timezone_set('America/Chicago');
  
  if ($day == "Saturday")
  {
      echo "<p><b>SATURDAY SPECIALS</b></p>";
      echo "</div><div class=\"mod1\">";
      echo "<p>FOOD</p>";
      echo "<h3>Half priced desserts</h3>";
      echo "<p>DRINK</p>";
      echo "<h3>$1 off Seasonal Pints</h3>";
  
  }
  elseif ($day == "Sunday")
  {
      echo "<p><b>GAMEDAY SPECIALS</b></p>";
      echo "</div><div class=\"mod1\">";
      echo "<p>FOOD</p>";
      echo "<h3>One Free Kids Meal w/ each Adult Meal</h3>";
      echo "<p>DRINK</p>";
      echo "<h3>$3 on ALL Bottled Beers</h3>";    }
  elseif ($day == "Monday")
  {
      echo "<p><b>MONDAY SPECIALS</b></p>";
      echo "</div><div class=\"mod1\">";
      echo "<p>FOOD</p>";
      echo "<h3>$1 Tenders <br />(5 piece min.)</h3>";
      echo "<p>DRINK</p>";
      echo "<h3>$2 Lonestar Pints</h3>";  }
  elseif ($day == "Tuesday")
  {
      echo "<p><b>TUESDAY SPECIALS</b></p>";
      echo "</div><div class=\"mod1\">";
      echo "<p>FOOD</p>";
      echo "<h3>$.50 Boneless Wings <br /> (10 piece min.)</h3>";
      echo "<p>DRINK</p>";
      echo "<h3>$4 Margaritas</h3>";  }
  elseif ($day == "Wednesday")
  {
      echo "<p><b>WEDNESDAY SPECIALS</b></p>";
      echo "</div><div class=\"mod1\">";
      echo "<p>FOOD</p>";
      echo "<h3>Half price APPs!</h3>";
      echo "<p>DRINK</p>";
      echo "<h3>$3 shots of Jameson & Jager</h3>";
  }
  elseif ($day == "Thursday")
  {
      echo "<p><b>THURSDAY SPECIALS</b></p>";
      echo "</div><div class=\"mod1\">";
      echo "<p>FOOD</p>";
      echo "<h3>2 for $10 Wingzup Burgers</h3>";
      echo "<p>DRINK</p>";
      echo "<h3>$3 Draft Beers all day</h3>";
  }
  else
  {
      echo "<p><b>FRIDAY SPECIALS</b></p>";
      echo "</div><div class=\"mod1\">";
      echo "<p>FOOD</p>";
      echo "<h3>$2 Chili Pies</h3>";
      echo "<p>DRINK</p>";
      echo "<h3>$10 Pitchers (Bud Lt./Ziegenbock/Lone Star)</h3>";
  }
  
  ```
  
  **Tags:** templating, datetime
  
  > **Comments:**
  > **username_1**: You not gonna hardcode the daily menus into your template, username_0?  
  
  ---
  
  ## 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"`](http://twig.sensiolabs.org/doc/filters/date.html) and filter it with the [`date()`](http://twig.sensiolabs.org/doc/filters/date.html) filter to return it in the format you need (see the [list for supported parameters](https://www.php.net/manual/en/function.date.php)).
  
  Then do the [`if` / `elseif`](http://twig.sensiolabs.org/doc/tags/if.html) conditionals similar to how you'd do it in PHP. Another option would be to use the Craft specific [`switch`](http://buildwithcraft.com/docs/templating/switch) tag.
  
  ```none
  {% switch "now" | date("l") %}
  
      {% case "Monday" %}
          {# Do Monday stuff #}
  
      {% case "Tuesday" %}
          {# Do Tuesday stuff #}
  
      {% case "Wednesday" %}
          {# Do Wednesday stuff #}
  
      {# etc. #}
  
  {% endswitch %}
  
  ```
  
  
  ---
  
  