I have this part of the function, which gives me name of the months in English. How can I translate them to my local language (Serbian)?
$month_name = date(\
For all who struggle with German (and de_DE
), make sure you are using the right language code. Login to your server and run locale -a to see a list of all available ones. For me it shows:
C
C.UTF-8
de_AT.utf8
de_BE.utf8
de_CH.utf8
de_DE.utf8
de_LI.utf8
de_LU.utf8
...
You need to use one of those codes.
Then you can use:
date_default_timezone_set('Europe/Berlin');
setlocale(LC_ALL, 'de_DE.utf8');
$date_now = date('Y-m-d');
$month_available = strftime('%B %Y', strtotime($date_now));
$month_next = strftime('%B %Y', strtotime($date_now.' +1 month'));
and "März 2020" etc. get displayed correctly.