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

554
Views
PHP 8.1: strftime() está en desuso

Al actualizar a PHP 8.1, recibí un error con respecto a "strftime". ¿Cómo corrijo el código para mostrar correctamente el nombre completo del mes en cualquier idioma?

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

0

Elegí usar el paquete php81_bc/strftime composer como reemplazo.

Aquí la documentación .

Preste atención a que el resultado podría ser diferente del strftime nativo porque php81_bc/strftime usa una biblioteca diferente para el formateo con reconocimiento de la configuración regional (ICU).

Tenga en cuenta que la salida puede ser ligeramente diferente entre libc sprintf y esta función, ya que utiliza ICU.

over 4 years ago · Santiago Trujillo Report

0

Para mi querido y difunto strftime()... Encontré una manera de adaptarme con IntlDateFormatter::formatObject y aquí está el enlace para las referencias a los esquemas:

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

... Para aquellos que quieren formatear la fecha con mayor precisión

 <?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

strftime está obsoleto y DateTime::format() proporciona un reemplazo rápido e IntlDateFormatter::format() proporciona una solución más sofisticada.

Estos enlaces te ayudarán:

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

https://github.com/php/php-src/blob/1cf4fb739f7a4fa8404a4c0958f13d04eae519d4/ACTUALIZACIÓN#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!