Answers.Body: <p>This should do what you're looking for:</p>
  
  <pre><code>{% set closed = true %}
  
  {% for dayOfWeek in theCenter.openWeekDay %}
  
      {% if 'now'|date('N') == dayOfWeek and 'now'|date('Hi', 'America/Denver') &gt; theCenter.openTime|date('Hi') and 'now'|date('Hi', 'America/Denver') &lt; theCenter.closeTime|date('Hi') %}
          {% set closed = false %}
      {% endif %}
  
  {% endfor %}
  
  {% if closed %}
      &lt;h3&gt;The center is CLOSED&lt;/h3&gt;
  {% else %}
      &lt;h3&gt;The center is OPEN&lt;/h3&gt;
  {% endif %}
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-01-04T02:03:42.487Z
Answers.LastActivityDate: 2016-01-04T02:03:42.487Z
Answers.UserDisplayName: Brad Bell
Body: <p>I'm attempting to create something within my template using global values and checkboxes. What I need this to do is "if it's one of the days of the week marked as open, as selected by a checkbox, and the time is between X and Y, then display that we are open, otherwise, say we are closed".</p>
  
  <p>I have Monday through Sunday listed as checkboxes, and their values are set with Monday as 1, Tuesday as 2, etc, and I'm trying to compare it to 'now'|date('N'), which lists the day of the week as a number.</p>
  
  <pre><code>{% for dayOfWeek in theCenter.openWeekDay %}
  
      {% if 'now'|date('N') == dayOfWeek and 'now'|date('Hi', 'America/Denver') &gt; theCenter.openTime|date('Hi') and 'now'|date('Hi', 'America/Denver') &lt; theCenter.closeTime|date('Hi') %}
          &lt;h3&gt;We are OPEN&lt;/h3&gt;
      {% else %}
          &lt;h3&gt;We are CLOSED&lt;/h3&gt;
      {% endif %}
  
  {% endfor %}
  </code></pre>
  
  <p>I've selected Tuesday through Sunday as open by selecting their checkboxes in the globals form. The code above returns 5 'We are Closed' and 1 'We are Open' results. I just need it to check if today is one of the open days, and if it's between open and closing time, and display one result.</p>
  
  <p>I've tried this:</p>
  
  <pre><code>{% if 'now'|date('N') in dayOfWeek and 'now'|date('Hi', 'America/Denver') &gt; theCenter.openTime|date('Hi') and 'now'|date('Hi', 'America/Denver') &lt; theCenter.closeTime|date('Hi') %}
  </code></pre>
  
  <p>but it returns 6 'We are Closed'. I've been trying to figure this out for several hours, but the documentation doesn't seem to be made for what I want to do, and I'm probably looking in the wrong place.</p>
  
  <p>Any suggestions on how I could get this to work?</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>Here's the entire script:</p>
  
  <pre><code>{% if 'now'|date('z', 'America/Denver') &gt; theCenter.startWinterSeason|date('z') or 'now'|date('z', 'America/Denver') &lt; theCenter.endWinterSeason|date('z') %}
      {% for dayOfWeek in theCenter.openDaysWinter %}
          {% if dayOfWeek.selected and 'now'|date('N') == dayOfWeek and 'now'|date('Hi', 'America/Denver') &gt; theCenter.openTimeWinter|date('Hi') and 'now'|date('Hi', 'America/Denver') &lt; theCenter.closeTimeWinter|date('Hi') %}
              &lt;h3&gt;The center is OPEN&lt;/h3&gt;
          {% else %}
              &lt;h3&gt;The center is CLOSED&lt;/h3&gt;
          {% endif %}
      {% endfor %}
      &lt;div class="infoPane"&gt;
          &lt;p&gt;&lt;i class="uk-icon-clock-o"&gt;&lt;/i&gt;&amp;nbsp;{{ theCenter.hoursTitleWinter }}&lt;/p&gt;
          &lt;p&gt;Tuesday &amp;mdash; Saturday&lt;br&gt;{{ theCenter.openTimeWinter|date('g:i A') }} to {{ theCenter.closeTimeWinter|date('g:i A') }}&lt;/p&gt;
          &lt;p class="uk-text-small"&gt;{{ theCenter.timeNotes|raw }}&lt;/p&gt;
      &lt;/div&gt;
  
  {% elseif 'now'|date('z', 'America/Denver') &gt; theCenter.startSummerSeason|date('z') and 'now'|date('z', 'America/Denver') &lt; theCenter.endSummerSeason|date('z') %}
      {% for dayOfWeek in theCenter.openDaysSummer %}
          {% if dayOfWeek.selected and 'now'|date('N') == dayOfWeek and 'now'|date('Hi', 'America/Denver') &gt; theCenter.openTimeSummer|date('Hi') and 'now'|date('Hi', 'America/Denver') &lt; theCenter.closeTimeSummer|date('Hi') %}
              &lt;h3&gt;The center is OPEN&lt;/h3&gt;
          {% else %}
              &lt;h3&gt;The center is CLOSED&lt;/h3&gt;
          {% endif %}
      {% endfor %}
      &lt;div class="infoPane"&gt;
          &lt;p&gt;&lt;i class="uk-icon-clock-o"&gt;&lt;/i&gt;&amp;nbsp;{{ theCenter.hoursTitleSummer }}&lt;/p&gt;
          &lt;p&gt;Tuesday &amp;mdash; Saturday&lt;br&gt;{{ theCenter.openTimeSummer|date('g:i A') }} to {{ theCenter.closeTimeSummer|date('g:i A') }}&lt;/p&gt;
          &lt;p class="uk-text-small"&gt;{{ theCenter.timeNotes|raw }}&lt;/p&gt;
      &lt;/div&gt;
  {% else %}
      &lt;h3&gt;EPIC FAIL&lt;/h3&gt;
  {% endif %}
  </code></pre>
  
  <p>Which outputs this:</p>
  
  <p><a href="https://i.sstatic.net/WmcCe.jpg" rel="nofollow noreferrer"><img src="https://i.sstatic.net/WmcCe.jpg" alt="Output"></a></p>
  
  <p>I need it to only show the center is closed once.</p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2016-01-03T21:27:04.310Z
Comments.Text: I just setup a test case using virtually identical code and it worked as expected for me.  Is your Craft install set to `America/Denver` under Settings->General?  Also, have you seen https://github.com/pixelandtonic/StoreHours?
Comments.UserDisplayName: Brad Bell
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2016-01-03T21:42:02.947Z
Comments.Text: I'll test out Store Hours and see if that works. Is there more documentation available on it?
  
  Also, the timezone is indeed, set to Denver.
Comments.UserDisplayName: Dustin C
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2016-01-03T21:44:29.947Z
Comments.Text: I'm looking at this, and I realise that the reason it's spitting out "We are Closed" so many times is because it's stuck a loop. The hours are simple enough that we just want the hours listed on the site as "The center is open. Hours: Tuesday-Sunday, 9:00 AM to 4:30 PM" -- we don't want to list the hours out for each day of the week individually.
Comments.UserDisplayName: Dustin C
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2016-01-03T21:52:06.463Z
Comments.Text: Hey @BradBell -- thanks for the Store Hours suggestion, but it's not giving me the level of control that I would need. I'll need to stick with this one for now.
Comments.UserDisplayName: Dustin C
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2016-01-03T22:46:40.583Z
Comments.Text: I'm not following... the hours aren't being output at all, it's just looping on the days.  Is your `openTime` and `closeTime` date/time fields set to just display the times?
Comments.UserDisplayName: Brad Bell
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2016-01-04T01:29:18.287Z
Comments.Text: The hours are output farther on. I didn't include that part of the script for brevity sake, as this is what I was having issues with. :)
Comments.UserDisplayName: Dustin C
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2016-01-04T01:56:22.063Z
Comments.Text: @BradBell - Added the full script on the original post.
Comments.UserDisplayName: Dustin C
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2016-01-04T01:58:22.370Z
Comments.Text: Regardless, I was able to get it to work with your original code.  So I'd probably focus on that.
Comments.UserDisplayName: Brad Bell
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2016-01-04T02:00:35.027Z
Comments.Text: Oh, maybe I misunderstood.  If it's closed you only want it to show once?
Comments.UserDisplayName: Brad Bell
Tags: <checkboxes>
Title: Checkbox array for days of the week
ThreadText: # Checkbox array for days of the week
  
  (Asked by: username_0 on 2016-01-03)
  
  I'm attempting to create something within my template using global values and checkboxes. What I need this to do is "if it's one of the days of the week marked as open, as selected by a checkbox, and the time is between X and Y, then display that we are open, otherwise, say we are closed".
  
  I have Monday through Sunday listed as checkboxes, and their values are set with Monday as 1, Tuesday as 2, etc, and I'm trying to compare it to 'now'|date('N'), which lists the day of the week as a number.
  
  ```
  {% for dayOfWeek in theCenter.openWeekDay %}
  
      {% if 'now'|date('N') == dayOfWeek and 'now'|date('Hi', 'America/Denver') > theCenter.openTime|date('Hi') and 'now'|date('Hi', 'America/Denver') < theCenter.closeTime|date('Hi') %}
          <h3>We are OPEN</h3>
      {% else %}
          <h3>We are CLOSED</h3>
      {% endif %}
  
  {% endfor %}
  
  ```
  
  I've selected Tuesday through Sunday as open by selecting their checkboxes in the globals form. The code above returns 5 'We are Closed' and 1 'We are Open' results. I just need it to check if today is one of the open days, and if it's between open and closing time, and display one result.
  
  I've tried this:
  
  ```
  {% if 'now'|date('N') in dayOfWeek and 'now'|date('Hi', 'America/Denver') > theCenter.openTime|date('Hi') and 'now'|date('Hi', 'America/Denver') < theCenter.closeTime|date('Hi') %}
  
  ```
  
  but it returns 6 'We are Closed'. I've been trying to figure this out for several hours, but the documentation doesn't seem to be made for what I want to do, and I'm probably looking in the wrong place.
  
  Any suggestions on how I could get this to work?
  
  **EDIT**
  
  Here's the entire script:
  
  ```
  {% if 'now'|date('z', 'America/Denver') > theCenter.startWinterSeason|date('z') or 'now'|date('z', 'America/Denver') < theCenter.endWinterSeason|date('z') %}
      {% for dayOfWeek in theCenter.openDaysWinter %}
          {% if dayOfWeek.selected and 'now'|date('N') == dayOfWeek and 'now'|date('Hi', 'America/Denver') > theCenter.openTimeWinter|date('Hi') and 'now'|date('Hi', 'America/Denver') < theCenter.closeTimeWinter|date('Hi') %}
              <h3>The center is OPEN</h3>
          {% else %}
              <h3>The center is CLOSED</h3>
          {% endif %}
      {% endfor %}
      <div class="infoPane">
          <p><i class="uk-icon-clock-o"></i>&nbsp;{{ theCenter.hoursTitleWinter }}</p>
          <p>Tuesday &mdash; Saturday<br>{{ theCenter.openTimeWinter|date('g:i A') }} to {{ theCenter.closeTimeWinter|date('g:i A') }}</p>
          <p class="uk-text-small">{{ theCenter.timeNotes|raw }}</p>
      </div>
  
  {% elseif 'now'|date('z', 'America/Denver') > theCenter.startSummerSeason|date('z') and 'now'|date('z', 'America/Denver') < theCenter.endSummerSeason|date('z') %}
      {% for dayOfWeek in theCenter.openDaysSummer %}
          {% if dayOfWeek.selected and 'now'|date('N') == dayOfWeek and 'now'|date('Hi', 'America/Denver') > theCenter.openTimeSummer|date('Hi') and 'now'|date('Hi', 'America/Denver') < theCenter.closeTimeSummer|date('Hi') %}
              <h3>The center is OPEN</h3>
          {% else %}
              <h3>The center is CLOSED</h3>
          {% endif %}
      {% endfor %}
      <div class="infoPane">
          <p><i class="uk-icon-clock-o"></i>&nbsp;{{ theCenter.hoursTitleSummer }}</p>
          <p>Tuesday &mdash; Saturday<br>{{ theCenter.openTimeSummer|date('g:i A') }} to {{ theCenter.closeTimeSummer|date('g:i A') }}</p>
          <p class="uk-text-small">{{ theCenter.timeNotes|raw }}</p>
      </div>
  {% else %}
      <h3>EPIC FAIL</h3>
  {% endif %}
  
  ```
  
  Which outputs this:
  
  [![Output](https://i.sstatic.net/WmcCe.jpg)](https://i.sstatic.net/WmcCe.jpg)
  
  I need it to only show the center is closed once.
  
  **Tags:** checkboxes
  
  > **Comments:**
  > **username_1**: I just setup a test case using virtually identical code and it worked as expected for me.  Is your Craft install set to `America/Denver` under Settings->General?  Also, have you seen https://github.com/pixelandtonic/StoreHours?  
  > **username_0**: I'll test out Store Hours and see if that works. Is there more documentation available on it?  Also, the timezone is indeed, set to Denver.  
  > **username_0**: I'm looking at this, and I realise that the reason it's spitting out "We are Closed" so many times is because it's stuck a loop. The hours are simple enough that we just want the hours listed on the site as "The center is open. Hours: Tuesday-Sunday, 9:00 AM to 4:30 PM" -- we don't want to list the hours out for each day of the week individually.  
  > **username_0**: Hey @username_1 -- thanks for the Store Hours suggestion, but it's not giving me the level of control that I would need. I'll need to stick with this one for now.  
  > **username_1**: I'm not following... the hours aren't being output at all, it's just looping on the days.  Is your `openTime` and `closeTime` date/time fields set to just display the times?  
  > **username_0**: The hours are output farther on. I didn't include that part of the script for brevity sake, as this is what I was having issues with. :)  
  > **username_0**: @username_1 - Added the full script on the original post.  
  > **username_1**: Regardless, I was able to get it to work with your original code.  So I'd probably focus on that.  
  > **username_1**: Oh, maybe I misunderstood.  If it's closed you only want it to show once?  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2016-01-04. Score: 2 | Accepted answer
  
  This should do what you're looking for:
  
  ```
  {% set closed = true %}
  
  {% for dayOfWeek in theCenter.openWeekDay %}
  
      {% if 'now'|date('N') == dayOfWeek and 'now'|date('Hi', 'America/Denver') > theCenter.openTime|date('Hi') and 'now'|date('Hi', 'America/Denver') < theCenter.closeTime|date('Hi') %}
          {% set closed = false %}
      {% endif %}
  
  {% endfor %}
  
  {% if closed %}
      <h3>The center is CLOSED</h3>
  {% else %}
      <h3>The center is OPEN</h3>
  {% endif %}
  
  ```
  
  
  ---
  
  