strftime
Locale-formatted strftime using IntlDateFormatter (PHP 8.1 compatible)
This provides a cross-platform alternative to strftime() for when it will be removed from PHP.
Note that output can be slightly different between libc sprintf and this function as it is using ICU.
Original code: https://gist.github.com/bohwaz/42fc223031e2b2dd2585aab159a20f30
Original autor: BohwaZ
Requirements
- PHP >= 5.6
- ext-intl (Internationalization extension ICU)
Installation
Composer install
You can install this plugin into your application using composer:
-
Add php81_bc/strftime package to your project:
composer require php81_bc/strftime
-
Load the function PHP81_BC\strftime in your project
require 'vendor/autoload.php'; use function PHP81_BC\strftime;
Manual install
- Download php-8.1-strftime.php and save it to an accessible path of your project.
- Load the function PHP81_BC\strftime in your project
require 'php-8.1-strftime.php'; use function PHP81_BC\strftime;
Usage
use function PHP81_BC\strftime;
echo strftime('%A %e %B %Y %X', new \DateTime('2021-09-28 00:00:00'), 'fr_FR');
Original use
\setlocale(LC_TIME, 'fr_FR.UTF-8');
echo \strftime('%A %e %B %Y %X', strtotime('2021-09-28 00:00:00'));