<p><code>{{ now|date("H:i", "Europe/Paris") }}</code></p>

<p>As per: <a href="http://twig.sensiolabs.org/doc/filters/date.html" rel="noreferrer">http://twig.sensiolabs.org/doc/filters/date.html</a></p>

CC BY-SA 4.0
2019-07-23T12:45:02.190Z
Hi, how to do this same in php, i want to fetch entries based on user timezone.
inrsaurabh
CC BY-SA 3.0
2015-11-25T16:52:52.170Z
2015-11-25T16:52:52.170Z
andrew.welch
<p>First define an array of all the timezones you want to output the time with, plus what their “Standard Time”/“Daylight Savings time” abbreviations are:</p>

<pre><code>{% set locales = [
    { timezone: 'Australia/Sydney',    stAbbr: 'AEST', dstAbbr: 'AEDT' },
    { timezone: 'America/Los_Angeles', stAbbr: 'PST',  dstAbbr: 'PDT' },
    { timezone: 'America/New_York',    stAbbr: 'EST',  dstAbbr: 'EDT' },
    { timezone: 'Europe/London',       stAbbr: 'GMT',  dstAbbr: 'BST' },
] %}
</code></pre>

<p>Then loop through them, outputting your date in those timezones, plus showing the correct “Standard Time”/“Daylight Savings Time” abbreviation:</p>

<pre><code>{% for locale in locales %}
    {# Output the date/time in this timezone #}
    {{ date()|date('F j ga', locale.timezone) }}

    {# Is that timezone currently observing Standard Time? #}
    {% if date()|date('I', locale.timezone) == '0' %}
        {{ locale.stAbbr }}
    {% else %}
        {{ locale.dstAbbr }}
    {% endif %}
{% endfor %}
</code></pre>

CC BY-SA 3.0
2015-11-25T17:08:48.097Z
Gives me the same time for every locale. I'm using {{ now|date("H:i", locale.timezone) }}. So for London the same time as New York.
Johannes Lamers
CC BY-SA 3.0
2015-11-25T17:28:36.810Z
@JohannesLamers What happens if you replace `now` with `date()`?
Brandon Kelly
CC BY-SA 3.0
2015-11-25T18:08:59.660Z
Its working now with {{ date()|date("H:i", locale.timezone) }}
Johannes Lamers
CC BY-SA 3.0
2015-11-25T23:34:30.717Z
@JohannesLamers Cool, just updated the code to use `date()`.
Brandon Kelly
CC BY-SA 3.0
2015-11-25T16:56:18.297Z
2015-11-25T23:34:05.267Z
2015-11-25T23:34:05.267Z
Brandon Kelly
<p>How can I get the current date / time for specific timezones?</p>

<p>My local time is easy: </p>

<pre><code>{{ now|date("H:i") }}
</code></pre>

<p>So how can I get this for New York? or Singapore?</p>

<templating><datetime><timezone>
Get current date / time in specific timezone?
# Get current date / time in specific timezone?

(Asked by: username_0 on 2015-11-25)

How can I get the current date / time for specific timezones?
My local time is easy: 
{{ now|date("H:i") }}

So how can I get this for New York? or Singapore?

**Tags:** templating, datetime, timezone

---

## 2 answers

### Answer by username_3 on 2015-11-25. Score: 5 | Accepted answer

First define an array of all the timezones you want to output the time with, plus what their “Standard Time”/“Daylight Savings time” abbreviations are:
{% set locales = [
    { timezone: 'Australia/Sydney',    stAbbr: 'AEST', dstAbbr: 'AEDT' },
    { timezone: 'America/Los_Angeles', stAbbr: 'PST',  dstAbbr: 'PDT' },
    { timezone: 'America/New_York',    stAbbr: 'EST',  dstAbbr: 'EDT' },
    { timezone: 'Europe/London',       stAbbr: 'GMT',  dstAbbr: 'BST' },
] %}

Then loop through them, outputting your date in those timezones, plus showing the correct “Standard Time”/“Daylight Savings Time” abbreviation:
{% for locale in locales %}
    {# Output the date/time in this timezone #}
    {{ date()|date('F j ga', locale.timezone) }}

    {# Is that timezone currently observing Standard Time? #}
    {% if date()|date('I', locale.timezone) == '0' %}
        {{ locale.stAbbr }}
    {% else %}
        {{ locale.dstAbbr }}
    {% endif %}
{% endfor %}

> **Comments:**
> **username_0**: Gives me the same time for every locale. I'm using {{ now|date("H:i", locale.timezone) }}. So for London the same time as New York.  
> **username_3**: @JohannesLamers What happens if you replace `now` with `date()`?  
> **username_0**: Its working now with {{ date()|date("H:i", locale.timezone) }}  
> **username_3**: @JohannesLamers Cool, just updated the code to use `date()`.  

---

### Answer by username_1 on 2015-11-25. Score: 5

`{{ now|date("H:i", "Europe/Paris") }}`

As per: <http://twig.sensiolabs.org/doc/filters/date.html>

> **Comments:**
> **username_2**: Hi, how to do this same in php, i want to fetch entries based on user timezone.  

---

