Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

549
Views
PHP 8.1: strftime() is deprecated

When upgrading to PHP 8.1, I got an error regarding "strftime". How do I correct the code to correctly display the full month name in any language?

 $date = strftime("%e %B %Y", strtotime('2010-01-08'))
over 4 years ago · Santiago Trujillo
3 answers
Answer question

0

I've chosen to use php81_bc/strftime composer package as a replacement.

Here the documentation.

Pay attention that the output could be different from native strftime 'cause php81_bc/strftime uses a different library for locale aware formatting (ICU).

Note that output can be slightly different between libc sprintf and this function as it is using ICU.

over 4 years ago · Santiago Trujillo Report

0

To my dear and late strftime()... I found a way to adapt with IntlDateFormatter::formatObject and here is the link for the references to the schemas:

https://unicode-org.github.io/icu/userguide/format_parse/datetime/#date-field-symbol-table

... For those who want to format the date more precisely

<?php 

// "date_default_timezone_set" may be required by your server
date_default_timezone_set( 'Europe/Paris' );

// make a DateTime object 
// the "now" parameter is for get the current date, 
// but that work with a date recived from a database 
// ex. replace "now" by '2022-04-04 05:05:05'
$dateTimeObj = new DateTime('now', new DateTimeZone('Europe/Paris'));

// format the date according to your preferences
// the 3 params are [ DateTime object , ICU date scheme, string locale ]
$dateFromatted = 
IntlDateFormatter::formatObject( 
  $dateTimeObj, 
  'eee d MMMM y à HH:mm', 
  'fr' 
);

// test :
echo ucwords($dateFromatted);

// output : Jeu. 7 Avril 2022 à 04:56

?>
over 4 years ago · Santiago Trujillo Report

0

The strftime is obsolete and DateTime::format() provide a quick replacement and IntlDateFormatter::format() provied a more sophisticated slution.

this links will be help you:

https://github.com/modxcms/revolution/issues/15864

https://github.com/php/php-src/blob/1cf4fb739f7a4fa8404a4c0958f13d04eae519d4/UPGRADING#L379-L381

https://www.php.net/manual/en/datetime.format.php

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!