Skip to content
Advertisement

Months name is not showing in German in PHP?

Hi I am trying to display months name in PHP but it is not showing in German language in MYSQL, my date is showing as 2021-01-23 which I converted into months by using PHP function Month(), MONTH(beginn)

PHP Code –

date_default_timezone_set('Europe/Berlin');
setlocale(LC_ALL, 'de_DE.utf8');
echo  (date("F",strtotime($month)));

Advertisement

Answer

Try this

date_default_timezone_set('Europe/Berlin');
$loc=setlocale(LC_ALL, 'de_DE@euro', 'de_DE', 'deu_deu');
echo utf8_encode(strftime("%B",strtotime("2021-06-23")));

Convert June to Juni

Edit: some characters in German are utf8 enncoded utf8_encode function solve it. Like März

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement