Created
May 23, 2016 11:36
-
-
Save smichaelsen/da082c84fb282e9db9daedea589968e8 to your computer and use it in GitHub Desktop.
PHP Date localization
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
setlocale(LC_TIME, 'de_DE'); | |
echo (new DateTime())->format('F'); // May | |
echo strftime('%B', time()); // Mai | |
// BUT WHY!? |
PHP Manual for DateTime->format says "This method does not use locales. All output is in English."
For strftime it says "Format the time and/or date according to locale settings. Month and weekday names and other language-dependent strings respect the current locale set with setlocale()."
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I'd assume your
LC_ALL
or other locale is set tode_DE
andstrftime
is using that locale while->format
isn't…