php81_bc / strftime
Locale-formatted strftime using IntlDateFormatter (PHP 8.1 compatible)
Installs: 428 985
Dependents: 4
Suggesters: 0
Security: 0
Stars: 35
Watchers: 7
Forks: 14
Open Issues: 2
Requires
- php: >=7.1.0
- ext-intl: *
Requires (Dev)
- phpunit/phpunit: @stable
README
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
Table of contents
Requirements
- PHP >= 7.1.0
- 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
<?php 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
<?php 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'));
Formats
Day
Week
NOTE: All week formats are two-digit, with leading zeros.