Forum
Where do I set locale for srftime dates?
Hi there!
I'm including an editable region in my index.php using a custom HTML template. In the template, I define a date content using srftime formatting (because I need hours and minutes for the events). This works great, but the content is outputted in English.
The setlocale() PHP-function is mentioned in the date documentation. Butw here do I use setlocale() to change my event dates to German? In the index.php, or in my template? I'm suspecting it could also be a cache-error. I'm working directly on the web server, uploading index.php and my templates every time I make changes. My web server is unix-based.
Thanks! Jannis
The best place is probably in the
perch/config/config.php
file.Thanks a lot, Drew, I now have German Month names by adding
setlocale('LC_ALL', 'de_DE');
to my perch config.php!A note though, this doesn’t seem to work with
perch_content()
, but only displays correctly when usingperch_content_custom()
.Make sure you've saved your content after making the config change. It's cached.
Something still doesn’t work (probably caused by my non-existent knowledge of PHP):
https://stage.gesangverein-wallrabenstein.de/termine.php
The left column shows a template that uses srftime-Dates (I need this because of the translated months). The right column shows a template that uses PHP dates.
The last dates in both columns are set to 31 Dec 2014 in Perch.
Notice that when using srftime, the year gets offset to 2015. This happens from 29th to 31th of December, when I set the date to 28 Dec 2014, the year shows correctly.
I have the following date configuration set in my config.php:
Try:
No luck, still showing as 2015.
The date works fine with the blog app, which I use on this page: https://stage.gesangverein-wallrabenstein.de/berichte/
I set one of the posts to 31 December 2013 and it works. I don’t use time in this template, just the date, but with srftime-formatting.
I don't think I understand the problem, then. What codes are you using? What output are you getting, and what output are you expecting?