1

I am working with SocialEngine4 with Zend. Translator of this application working fine. But we want some different date format for German language so we implemented new code. But it is not translating "March" properly. It is showing "21. M�rz 2015" date instead of "21. März 2015".

I used following code for this change

setlocale(LC_TIME, 'de_DE', 'deu_deu');
$date = strftime ("%d. %B %Y",strtotime($date));
setlocale(LC_ALL,NULL);
echo $date;

Please let me know whats the wrong here.

Gokul Shinde
  • 957
  • 3
  • 10
  • 30
  • I tried with your code and it gives me correct output i.e. "23. März 2015" . It seems your $date format is not correct. Try daye('Y-m-d') there at once. You will come to know what is the problem.Or where ever you want to display there put the charset to "utf-8-bin". – Alive to die - Anant Mar 23 '15 at 10:25
  • UTF-8 all the way through; this covers everywhere you should set the charset though, in this instance, the database and connector bit aren't really relevant : http://stackoverflow.com/questions/279170/utf-8-all-the-way-through – CD001 Mar 23 '15 at 10:27
  • Also, be sure to echo $date INSIDE the dom, not OUTSIDE of the dom, if you've set the correct charset in your HTML document. – briosheje Mar 23 '15 at 10:27

1 Answers1

0

In the page where the output is displayed, make sure that the charset is set to utf-8.

You can do that by adding the following line to the header.

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

By doing that there should be no need to convert the German Umlaute to entity names.

However if for some weird reason it will still not be working, you can also simply convert all special characters to their entity name equivalent:

echo htmlentities($date);

Like that it should work for sure.

ksbg
  • 3,214
  • 1
  • 22
  • 35