PHP strftime outputs wrong format despite correct timezone

荒凉一梦 提交于 2019-12-02 13:17:21

The time zone has no effect on how dates and times are presented, for that you need to set the locale. There are no standards for locale names, but fortunately PHP's setlocale() function will take multiple locale names, stopping at the first successful one.

// just a few common name formats
setlocale(LC_TIME, ["fr_FR.utf8", "fr_FR@euro", "fr_UTF8", "fr_FR", "french"]);
echo strftime("%d %B %Y", time());

I tried:

setlocale(LC_ALL, 'fr_utf8');


echo strftime("%d %B %Y", time());

and got:

16 novembre 2018

after setting the timezone to Europe/Paris, Use echo date('d-M-Y') and it will display your desired time. it worked for me

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!