Something went wrong while trying to load the full version of this site. Try hard-refreshing this page to fix the error.

Date by strftime is broken

Gizmo

Hi @mad !
I think I found a bug?..
When using locale settings and strftime date format I get crap instead of localized date.
If I set ru_RU locale and A as a Format Date Post then I get something like "68400000" as a post date.
But if I use this code then I see correct date display.
<?php
setlocale(LC_TIME, "C");
echo strftime("%A");
setlocale(LC_TIME, "ru_RU");
echo strftime(" in russian - %A,");
?>

Any ideas?


mad

Gizmo It is unfortunately not a bug and also mentioned in the release notes. The strftime function is deprecated in PHP since its latest version and therefore had to be removed in order to avoid compatibility issues with all future versions of PHP. I am aware that this is a breaking change that unfortunately can not be avoided since I have no influence in that matter. PHP 8.1 introduced many breaking changes, even though it is only a minor version and all PHP applications have somehow to deal with this now.

But there is a new alternative available in order to specify a locale. You can use the ICU syntax instead and all will be good. There is also an updated description in the docs for dateFormat with examples.

I hope this helps and the migration to the next PHP version will be less painful for all of us!

Cheers!


Gizmo

mad
Thank you so much for this clarification!
I really appreciate your dedication to user support! I mean really, mad you are a boss!


mad

Gizmo Thank you! 😊