PHP Date, International month names?

Solution:
Usesetlocale
andstrftime
to get a localized version of the date string.
Example from PHP Docs - http://php.net/manual/en/function.setlocale.php :
/* Set locale to Dutch */
setlocale(LC_ALL, 'nl_NL');
/* Output: vrijdag 22 december 1978 */
echo strftime("%A %e %B %Y", mktime(0, 0, 0, 12, 22, 1978));
/* try different possible locale names for german as of PHP 4.3.0 */
$loc_de = setlocale(LC_ALL, 'de_DE@euro', 'de_DE', 'de', 'ge');
echo "Preferred locale for german on this system is '$loc_de'";
Answer
Solution:
Facile, utilise strftime et setlocale.
setlocale(LC_ALL, 'fr_FR.utf-8'); // ou LC_TIME
echo strftime('%A');
"lundi"
Fais attention a utiliser la version utf-8 si tu attends une sortie unicode, sinon, la version normale te donnera du iso-8859-1(5).
In English for the rest of the community,strftime
respects the locale set, and uses the glibc (in the background). Ifdate
will always return englishstrftime
will respect thesetlocale
and give you the expected output in your language.
Share solution ↓
Additional Information:
Link To Answer People are also looking for solutions of the problem: foreach() argument must be of type array|object, null given
Didn't find the answer?
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Similar questions
Find the answer in similar questions on our website.
Write quick answer
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.