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?

  • 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
    Commented Feb 15, 2017 at 2:18
  • Sorry, I was just about to answer this question myself. See #help channel in Slack! ;-)
    – carlcs
    Commented Feb 15, 2017 at 2:19
  • lol - of course. i'd expect nothing less from you. :)
    – Brad Bell
    Commented Feb 15, 2017 at 2:22

1 Answer 1


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 }}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.