Language of strftime

Hi,

this is not directly Kirby related but I hope you can help me :smile:

I use

strftime('%B %Y', $page->date())

To get the date on my Bogl page (http://tobiw.de/tbdm/layout-1) and on my local host the month is correctly printed in german but on the server it is in english. I have access to several PHP options/settings but I don’t know where to change what …

Best,
Tobi

You can use the setlocale() function to change the strings used by PHP into different localizations. You can find some more info here:

http://php.net/manual/en/function.setlocale.php

You may also find this quick guide helpful:

http://www.webassist.com/tutorials/Display-date-and-time-in-your-own-language-format

Kirby has the locale option for this purpose.

@luxlogica Thanks but adding

<?php setlocale(LC_TIME, "no_NO"); ?>

to my header snippet doesn’t help.

@lukasbestle: I know but I have a multi lang set up … how should I set the variable in that case. Of course the date string should match the selected language …

And why does it work on my local machine but not on my server?

You can pass the locale to the languages option as well: http://getkirby.com/docs/languages/setup

Probably the default locale on your local machine is set to German in php.ini, while the server’s locale is English.

This is already set up in my config file … these are the lines:

c::set('languages', array(
  array(
    'code'    => 'de',
    'name'    => 'Deutsch',
    'default' => true,
    'locale'  => 'de_DE',
    'url'     => '/',
  ),
  array(
    'code'    => 'en',
    'name'    => 'English',
    'locale'  => 'en_US',
    'url'     => '/en',
  ),
));

Probably the default locale on your local machine is set to German in php.ini, while the server’s locale is English.

But on my local machine the language of the date format switches correctly together with the site language. So, it can’t be a default setting, can it?

Ah, alright.
No, if switching works locally, you are doing it right.

A reason can be that your server either does not support the German locale or it is named differently (PHP uses the system-wide locales).
You can try de_DE.utf8 and de_DE.UTF-8.

Great :slight_smile: adding the .utf8 part solved the problem. Thank!