<p>Twig’s <code>date</code> filter is aware of the current Craft locale, so you should be able to create a DateTime after composing a string that the filter accepts (see PHP <a href="http://www.php.net/en/strtotime" rel="nofollow noreferrer"><code>strtotime</code> function</a> docs, which the filter uses behind the scenes).</p>

<pre><code>{% set day = 1 %}
{% set month = 'juni' %}
{% set year = 2016 %}

{% set dateString = [day, month, year]|join(' ') %}
{% set date = dateString|date %}

{{ date }}
</code></pre>

CC BY-SA 3.0
2017-02-15T02:20:19.960Z
2017-02-15T02:39:40.207Z
2017-02-15T02:39:40.207Z
carlcs
<p>I've got News Archive pages that display all entries posted in a certain month/year. For example June 2016 shows all entries created in June of 2016!</p>

<p>I'm fetching the entries based on <code>craft.request.segment</code> (as the URL ends in /june/2016 etc). This works great for all English months, but when my URL says /juni/2016 (the German month name) it can't find any entries??</p>

<pre><code>{% set month = craft.request.segment(2) %}
{% set year = craft.request.segment(3) %}
</code></pre>

<p>It's defintely a translation thing. Anyone know how <code>craft.request.segment</code> can work with locales (German and simplified Chinese) too?</p>

CC BY-SA 3.0
2017-02-15T02:18:09.050Z
Does your URI structure change for German so that it's in a different segment?  i.e. site.com/de/archives/juni/2016 vs. site.com/archives/june/2016?
Brad Bell
CC BY-SA 3.0
2017-02-15T02:19:05.717Z
Sorry, I was just about to answer this question myself. See #help channel in Slack! ;-)
carlcs
CC BY-SA 3.0
2017-02-15T02:22:18.213Z
lol - of course.  i'd expect nothing less from you. :)
Brad Bell
<templating><localization><datetime>
Archive pages with full month names?
# Archive pages with full month names?

(Asked by: username_0 on 2017-02-15)

I've got News Archive pages that display all entries posted in a certain month/year. For example June 2016 shows all entries created in June of 2016!
I'm fetching the entries based on craft.request.segment (as the URL ends in /june/2016 etc). This works great for all English months, but when my URL says /juni/2016 (the German month name) it can't find any entries??
{% set month = craft.request.segment(2) %}
{% set year = craft.request.segment(3) %}

It's defintely a translation thing. Anyone know how craft.request.segment can work with locales (German and simplified Chinese) too?

**Tags:** templating, localization, datetime

> **Comments:**
> **username_1**: Does your URI structure change for German so that it's in a different segment?  i.e. site.com/de/archives/juni/2016 vs. site.com/archives/june/2016?  
> **username_0**: Sorry, I was just about to answer this question myself. See #help channel in Slack! ;-)  
> **username_1**: lol - of course.  i'd expect nothing less from you. :)  

---

## 1 answers

### Answer by username_0 on 2017-02-15. Score: 1 | Accepted answer

Twig’s date filter is aware of the current Craft locale, so you should be able to create a DateTime after composing a string that the filter accepts (see PHP strtotime function docs, which the filter uses behind the scenes).
{% set day = 1 %}
{% set month = 'juni' %}
{% set year = 2016 %}

{% set dateString = [day, month, year]|join(' ') %}
{% set date = dateString|date %}

{{ date }}


---

