Answers.Body: <p>You can set the site's timezone in Craft, but you won't get different timezones for your locales with that (locales != timezones btw.). But what you can do is to use Twig's <code>|date</code> filter which allows you to specify a different timezone for the output (<a href="https://php.net/manual/en/timezones.php" rel="nofollow">list of supported timezones</a>). If you create your own <code>DateTime</code> object by joining strings, you have to add a timezone here to give the filter a basis for its calculations. Make this match your Craft settings.</p>
  
  <p>The following example works without the Localization package. </p>
  
  <pre><code>{# Set locale time to GMT+2 #}
  {% set localeTime = "0:00 +0200" %}
  
  &lt;table&gt;
      &lt;tr&gt;
          &lt;th&gt;Local Time&lt;/th&gt;&lt;th&gt;Sao Paulo&lt;/th&gt;&lt;th&gt;Manaus&lt;/th&gt;
      &lt;/tr&gt;
  
      {% for hour in 0..23 %}
          {% for min in [0, 15, 30, 45] %}
  
              &lt;tr&gt;
                  {# Join time segments in a format supported by strtotime #}
                  {% set timeStep = ['+ ', hour, ' hours ', min, ' minutes']|join() %}
  
                  {# Modify the locale time and output in chosen timezone #}
                  &lt;td&gt;{{ localeTime|date_modify(timeStep)|date('H:i') }}&lt;/td&gt;
                  &lt;td&gt;{{ localeTime|date_modify(timeStep)|date('H:i', "America/Sao_Paulo") }}&lt;/td&gt;
                  &lt;td&gt;{{ localeTime|date_modify(timeStep)|date('H:i', "America/Manaus") }}&lt;/td&gt;
              &lt;/tr&gt;
  
          {% endfor %}
      {% endfor %}
  &lt;/table&gt;
  </code></pre>
  
  <p>To bring the site's currently requested locale into the game, just do some comparisons on <code>craft.locale</code>.</p>
  
  <pre><code>{{ craft.locale == 'de-DE' ? localeTime|date('H:i') }}
  {{ craft.locale == 'pt-BR' ? localeTime|date('H:i', "America/Sao_Paulo") }}
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-06-18T12:20:24.880Z
Answers.LastActivityDate: 2014-06-18T13:51:32.733Z
Answers.LastEditDate: 2014-06-18T13:51:32.733Z
Answers.UserDisplayName: carlcs
Body: <p>Is there a way to loop through a day in 15-minute intervals, with the output of said intervals being localizable? This (cringe-worthy) snippet should help explain what I'm trying to accomplish:</p>
  
  <pre><code>&lt;ul&gt;
      {% for hour in 0..23 %}
          {% for min in [0, 15, 30, 45] %}
  
              {% set foo = [hour, min]|join(':')|date('H:i')|date_modify('+0 days') %}
              &lt;li&gt;{{ foo.localeTime() }}&lt;/li&gt;
  
          {% endfor %}
      {% endfor %}
  &lt;/ul&gt;
  </code></pre>
  
  <p>For me, that snippet results in the unusual error <code>Method "localeTime" for object "DateTime" does not exist</code>.</p>
  
  <p>(This question was asked on g+ by Chris Davis. I copied it to SE, as I didn't want to answer it there!)</p>
  
Tags: <datetime><filter><timezone>
Title: Output DateTime in that timezone related to the current locale?
ThreadText: # Output DateTime in that timezone related to the current locale?
  
  (Asked by: username_0 on 2014-06-18)
  
  Is there a way to loop through a day in 15-minute intervals, with the output of said intervals being localizable? This (cringe-worthy) snippet should help explain what I'm trying to accomplish:
  
  ```
  <ul>
      {% for hour in 0..23 %}
          {% for min in [0, 15, 30, 45] %}
  
              {% set foo = [hour, min]|join(':')|date('H:i')|date_modify('+0 days') %}
              <li>{{ foo.localeTime() }}</li>
  
          {% endfor %}
      {% endfor %}
  </ul>
  
  ```
  
  For me, that snippet results in the unusual error `Method "localeTime" for object "DateTime" does not exist`.
  
  (This question was asked on g+ by Chris Davis. I copied it to SE, as I didn't want to answer it there!)
  
  **Tags:** datetime, filter, timezone
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_0 on 2014-06-18. Score: 3 | Accepted answer
  
  You can set the site's timezone in Craft, but you won't get different timezones for your locales with that (locales != timezones btw.). But what you can do is to use Twig's `|date` filter which allows you to specify a different timezone for the output ([list of supported timezones](https://php.net/manual/en/timezones.php)). If you create your own `DateTime` object by joining strings, you have to add a timezone here to give the filter a basis for its calculations. Make this match your Craft settings.
  
  The following example works without the Localization package.
  
  ```
  {# Set locale time to GMT+2 #}
  {% set localeTime = "0:00 +0200" %}
  
  <table>
      <tr>
          <th>Local Time</th><th>Sao Paulo</th><th>Manaus</th>
      </tr>
  
      {% for hour in 0..23 %}
          {% for min in [0, 15, 30, 45] %}
  
              <tr>
                  {# Join time segments in a format supported by strtotime #}
                  {% set timeStep = ['+ ', hour, ' hours ', min, ' minutes']|join() %}
  
                  {# Modify the locale time and output in chosen timezone #}
                  <td>{{ localeTime|date_modify(timeStep)|date('H:i') }}</td>
                  <td>{{ localeTime|date_modify(timeStep)|date('H:i', "America/Sao_Paulo") }}</td>
                  <td>{{ localeTime|date_modify(timeStep)|date('H:i', "America/Manaus") }}</td>
              </tr>
  
          {% endfor %}
      {% endfor %}
  </table>
  
  ```
  
  To bring the site's currently requested locale into the game, just do some comparisons on `craft.locale`.
  
  ```
  {{ craft.locale == 'de-DE' ? localeTime|date('H:i') }}
  {{ craft.locale == 'pt-BR' ? localeTime|date('H:i', "America/Sao_Paulo") }}
  
  ```
  
  
  ---
  
  