1
\$\begingroup\$

I saw that strftime is deprecated in PHP 8.1. I saw I can use a class include in intl but I'm not sure to understand how to use It.

On my site I use this function with the array $datesToConvert{020222, 030222, ...} which means "02 Février 2022"

function compareDate($date1, $date2){
        return strtotime($date2) - strtotime($date1);
    }
    usort($datesToConvert, "compareDate");

    //Generate Array titles and Array 
    foreach($datesToConvert as $element){
        $titles[] = "Vidéo du " . strftime('%d', strtotime($element)) . " " . ucfirst(strftime('%B', strtotime($element)));
    }

The Output is like "Vidéo du 02 Février"

May I have to rewrite my code in another way ?

Regards.

ps : sorry for my poor english i'm french.

\$\endgroup\$
5
  • 1
    \$\begingroup\$ as for me this question is good on Stackoverflow.com, not on Code Review. Using Google I even found on Stackoverflow: PHP 8.1: strftime() is deprecated - Stack Overflow and also some post (which you can find also in comments on question on stackoverflow) strftime and gmstrftime functions are deprecated - PHP 8.1 • PHP.Watch \$\endgroup\$
    – furas
    Mar 3, 2022 at 14:18
  • 1
    \$\begingroup\$ Thank you for the link I will study this solution. \$\endgroup\$ Mar 3, 2022 at 14:32
  • \$\begingroup\$ So is this question off-topic because it does not work as coded? \$\endgroup\$ Mar 4, 2022 at 0:27
  • 1
    \$\begingroup\$ If you are going from PHP8.1 and up, this looks simple: 3v4l.org/XGsCA but I'm not sure if I should post an answer. I'll wait to hear from more experienced content curators. \$\endgroup\$ Mar 4, 2022 at 0:40
  • \$\begingroup\$ @mickmackusa after reviewing this it seems on-topic; yes deprecated warnings, if not suppressed, could cause things to break (e.g. code using it from via XHR requests) but that doesn't mean this code is broken \$\endgroup\$ Apr 14, 2022 at 17:15

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.