PHP date() in foreign languages - e.g. Mar 25 Aoû 09 [duplicate]
I think you can't get away from doing so without setting LOCALE:
<?phpsetlocale(LC_ALL, 'fr_FR');echo strftime("%A %e %B %Y");?>
Some details on strftime:http://us2.php.net/manual/en/function.strftime.php
I think that the best way to do it with strftime
and setlocale
functions. But it will not work if your server has no needed locale installed (in current questions it is fr_FR
).
Code bellow throw an exception if locale change will be unsuccessful
<?php$result = setlocale(LC_ALL, 'fr_FR');if($result === false){ throw new \RuntimeException( 'Got error changing locale, check if locale is installed on the system' );}$dayOfMonth = '%e';//if it is Windows we will use %#d as %e is not supportedif (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') { $dayOfMonth = '%#d';}//Mar 25 Aoû 09 - month shortname, day of month, day shortname, year last two digitsecho strftime("%b $dayOfMonth %a %y");