4

I'm doing this:

{# Get events from `events` section in desired sort order #}
{% set allEvents = craft.entries.section('events').order('eventsDate asc') %}

{# Loop through `allEvents` and print the list #}
{% for event in allEvents %}
    <li>{{ event.title }} - {{ event.eventsDate|date('j F, Y') }}</li>
{% endfor %}

I guess I can do something with this: http://php.net/manual/en/datetime.formats.date.php, but I need to display months in my native language, which is slightly different from how Craft outputs it.

For example I'd like it to say "7 des", not "07 dec", "15 mai", not "15th may" and so on.

  • Sorry for the closing, Oyvind. Didn't read your question properly enough and thought Marion is right, that you will find an answer in that other Q/A. Voted to reopen this! – carlcs Jul 15 '14 at 19:06
  • Which primary locale (language) did you choose during the installation? – carlcs Jul 15 '14 at 19:30
  • My Craft installation is english. Its better that way, when reading documentation and so on. The only language tweak I need to do is for how months is printed. :) – osh Jul 15 '14 at 20:24
3

Yes, the date() filter you use (see Twig docs) allows you to format dates with the same formating characters as the php date function takes. All language dependent parts are returned in the language of the current locale. I don't know if you can change that primary locale in the control panel, but you could do that in the DB.

As you noted in the comments to your question, you want the CP to be in english. This is possible even if you set the site's locale to another language; the site's locale and the user language for the CP are different things.

| improve this answer | |
  • I guess I should give it a try then. How do I set the site's locale to another language without doing any harm? – osh Jul 16 '14 at 6:26
  • @Oyvind as I wrote, I think the only way to change the primary locale is to do it in the database directly ('craft-locales' table → 'locale' column). Change this to your desired front-end locale (eg. 'it' with all lowercase). – carlcs Jul 16 '14 at 11:33
  • Cheers, that worked fine for me. – erwinheiser Dec 5 '14 at 16:28
1

I think Multilingual Dates where date format varies pretty much covers it.

For details on date formats you will want to look at php's date format documentation

| improve this answer | |
  • I'm not using Craft multilangual though. Its just a tweak for this one thing. So, the post 'Multilingual Dates where date format varies' doesn't help me much. – osh Jul 15 '14 at 18:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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