php81_bc/strftime

Locale-formatted strftime using IntlDateFormatter (PHP 8.1 compatible)

0.7.6 2024-11-19 14:01 UTC

This package is auto-updated.

Last update: 2024-11-19 14:02:48 UTC


README

GitHub Workflow GitHub license GitHub release Packagist Packagist Downloads GitHub issues GitHub forks GitHub stars

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

TOC

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;

TOC

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;

TOC

Usage

  use function PHP81_BC\strftime;
  echo strftime('%A %e %B %Y %X', new \DateTime('2021-09-28 00:00:00'), 'fr_FR');

TOC

Original use

  \setlocale(LC_TIME, 'fr_FR.UTF-8');
  echo \strftime('%A %e %B %Y %X', strtotime('2021-09-28 00:00:00'));

TOC

Formats

Day

TOC

Week

NOTE: All week formats are two-digit, with leading zeros.

TOC

Month

TOC

Year

TOC

Time

TOC

Time and Date Stamps

TOC

Miscellaneous

TOC