php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #74982 strftime %P not working on Alpine Linux
Submitted: 2017-07-24 18:18 UTC Modified: 2021-04-07 16:36 UTC
From: ryan at ryanparman dot com Assigned: cmb (profile)
Status: Closed Package: Date/time related
PHP Version: 7.1.7 OS: Alpine Linux 3.4
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: ryan at ryanparman dot com
New email:
PHP Version: OS:

 

 [2017-07-24 18:18 UTC] ryan at ryanparman dot com
Description:
------------
I'm using the official PHP Docker container "php:7.1.7-fpm-alpine", which is based on Alpine Linux 3.4.

https://github.com/docker-library/php/blob/ddc7084c8a78ea12f0cfdceff7d03c5a530b787e/7.1/fpm/alpine/Dockerfile

When using strftime() on Alpine Linux, the %P modifier does not appear to be supported. When used, the resulting value is (bool) false.

The documentation on http://php.net/strftime says:

> Mac OS X only: The %P modifier is not supported in the Mac OS X implementation of this function.

I would assume that the follow-up to this ticket would either be:

1. To update the documentation to explain that this modifier is unsupported on Alpine Linux in addition to macOS. And/or…

2. That this is a proper bug, and Alpine Linux support should be fixed at some point.


Test script:
---------------
https://gist.github.com/skyzyx/55e2dea4e7f8fbc6854b2c81f51e8cf9

Expected result:
----------------
I expect the result to be `string(7) "06:12pm"`.

Actual result:
--------------
The actual result is `bool(false)`.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2017-07-24 19:10 UTC] danack@php.net
I believe this is the source for strftime on musl libc which is the C library used in Alphine linux:

http://git.musl-libc.org/cgit/musl/tree/src/time/strftime.c?id=ac0acd569e01735fc6052d43fdf57f3a07c93f3d

It does not appear to support "%P", which would make this a documentation issue.
 [2018-02-28 22:11 UTC] cmb@php.net
-Package: Unknown/Other Function +Package: Date/time related
 [2021-04-07 16:36 UTC] cmb@php.net
-Status: Open +Status: Verified -Assigned To: +Assigned To: cmb
 [2021-04-07 16:36 UTC] cmb@php.net
The documentation already mentions[1]:

| Not all conversion specifiers may be supported by your C
| library, in which case they will not be supported by PHP's
| strftime().

It shouldn't hurt to document that %P is not supported by musl,
though.

Note that there is an RFC[2] to deprecate strftime().

[1] <https://www.php.net/strftime>
[2] <https://wiki.php.net/rfc/deprecations_php_8_1>
 [2021-04-12 12:12 UTC] git@php.net
Automatic comment on behalf of cmb69
Revision: https://github.com/php/doc-en/commit/6936064e733f39045f471aad492abdeed7c4d2c6
Log: Fix #74982: strftime %P not working on Alpine Linux
 [2021-04-12 12:12 UTC] git@php.net
-Status: Verified +Status: Closed
 [2021-04-14 18:12 UTC] git@php.net
Automatic comment on behalf of mumumu
Revision: https://github.com/php/doc-ja/commit/2c7c178ce49d23b9c41518df99f5425cfa607dd7
Log: Fix #74982: strftime %P not working on Alpine Linux
 [2021-04-21 14:31 UTC] git@php.net
Automatic comment on behalf of Girgias
Revision: https://github.com/php/doc-fr/commit/c7383407f375cd1e0b5fee8db33d7423c7f98806
Log: Fix #74982: strftime %P not working on Alpine Linux
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Wed Jul 02 15:01:34 2025 UTC