This is about wrong display of spelled-out German month names which contain special characters (Umlaut, basically only the letter "ä" in "März" - German for March). I am trying to display it like "28. März 2012".

This is in Wordpress, BTW. In the header I have the <meta charset="utf-8"> tag. The corresponding template file contains the following line to get the month names in German:

setlocale (LC_ALL, 'de_AT@euro', 'de_AT', 'de', 'ge');

Actually, this code is for "Austrian German", but it shouldn't make a difference for the month of March = März.

For the page I am fetching a string from the database which represents a date, for example "18.03.2012". Then I convert that string to a "real" PHP date():

$date_start = date_create($date_string_from_database);

Since I need to compare that date to another timestamp, I convert it to a timestamp like this (adding a fixed time of 20:00):

And sometime later I create a formated date with spelled-out German month names from this timestamp like this:

$date_german = strftime("%e. %B %Y", $timestamp_start);

Now, in my localhost installation, this is displayed as expected:

But on the performance server, I get this:

All other special characters (including "ä") on that page are displayed correctly, it must have to do with the way the server handles that strftime function or the setlocale settings. FWIW, also the generated HTML code contains that "?" character instead of "ä". The PHP version is 5.6 in both cases.

Any idea what I could do to get it displayed correctly?

EDIT / ADDITION concerning possible duplicate: This has nothing to do with the charset meta tag (which I set, as I described in my question), and also not with encoding/decoding database results. The methos in the accepted answer works well for me, and that solution is not mentioned in the would-be-duplicate.

YESSS! I didn't think I would get a correct answer that fast - thank you very much!! (I just wonder why it works without that on localhost...)
– JohannesJan 23 at 20:36

@johannes Also check the list of available locales on the server system. There may be a specific locale that already supports utf-8. See for example this answer: stackoverflow.com/a/18229644/101087
– NineBerryJan 23 at 20:37

This is a bad solution. It only works if the locale happens to use ISO-8859-1 encoding, and breaks the same way in all other circumstances.
– deceze♦Jan 23 at 20:51

Today the PHP version changed, and unfortunately that method doesn't work anymore now. I got it to work by including setlocale(LC_TIME, "de_AT.UTF-8"); and then $date_german = strftime("%e. %B %Y", $timestamp_start);
– JohannesMar 16 at 21:24