What is happening with MODX? I am suddenly getting getting errors as below:
Deprecated: Function strftime() is deprecated in /my/server/directory/xdom/core/src/Revolution/Filters/modOutputFilter.php on line 459
The pages are generated OK and by shutting off the PHP error messages I can avoid having the served page start with ten error messages as above. BUT I prefer to figure out why.
I have the most current version on MODX installed 3.2.0pl, am running PHP8.3 on a shared server.
The PHP function strftime has been DEPRECATED as of PHP 8.1.0, but is still used in some places in MODX. In your case it looks like you use the output modifierstrftime or date.
The code still works OK, but generates these deprecation messages (if the server is configured to output them).
In both those examples you use the date output modifier.
The date output modifier is identical to the strftime output modifier and still uses the PHP function strftime():
So I guess the smart move is to finalize the date format in the snippet before sending it to the appropriate chunk and not bother with MODX’s date functions.
Well there are different ways to deal with this issue. You could just wait (and ignore the deprecation warnings). The output modifiers will eventually get changed. (Here’s a draft proposal for the change.)
Or you could create a custom output modifier to replace the built-in ones (as for example described here):
I have converted strftime() calls to use the IntlDateFormatter class. It requires enabling the Intl extension for PHP, but I think that’s usually enabled by default since the deprecation of strftime().
The documentation on it is not great, but it’s relatively easy once you get used to it, and I suspect that it will be faster than using the output filter. I have a MODX Blog post on it that’s scheduled for publication in April.
Thanks for the suggestions. I think, for our uses, updating the existing snippets to output date in the correct format is probably easier than customizing MODX.
Unlike most, we use MODX as a static page generator, not a live page server. So speed is not a big factor, since we build the pages, then upload them to Netlify for public access.