PHP strftime outputs wrong format despite correct timezone

前端 未结 3 809
野性不改
野性不改 2021-01-29 07:51

I configured my timezone to Europe/Paris in php.ini. When executing date_default_timezone_get() I do get the correct value.

Then, I expect strftime(\'

3条回答
  •  粉色の甜心
    2021-01-29 08:19

    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());
    

提交回复
热议问题