Req #79903 [NEW]: datetime: new format "p", same as "P" but returning "Z" for UTC
| From: | mail at gh01 dot de | Date: | Mon, 27 Jul 2020 16:35:42 +0000 |
| Subject: | Req #79903 [NEW]: datetime: new format "p", same as "P" but returning "Z" for UTC | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-228241@lists.php.net to get a copy of this message | ||
From: mail at gh01 dot de
Operating system:
PHP version: Next Major Version
Package: Date/time related
Bug Type: Feature/Change Request
Bug description:datetime: new format "p", same as "P" but returning
"Z" for UTC
Description:
------------
ISO 8601 differentiates between local time (without time zone), UTC with
letter "Z" and time offsets from UTC like "+02:00".
https://en.wikipedia.org/wiki/ISO_8601#Time_zone_designators
When formatting datetimes, it is sometimes desired to get the "Z" for
UTC times and otherwise the offset.
But at the moment there are only the formatting chars "O" (for "+0200"
etc.) and "P" (for "+02:00" etc.).
I suggest to add lower case "p" as another formatting char which behaves
the same as upper case "P" but returns "Z" for UTC datetimes.
https://github.com/php/php-src/pull/5896
Test script:
---------------
<?php
$datetime = new DateTime('2020-07-26 20:00:00', new
DateTimeZone('UTC'));
$datetime->format('Y-m-d\TH:i:sP'); // '2020-07-26T20:00:00+00:00'
$datetime->format('Y-m-d\TH:i:sp'); // '2020-07-26T20:00:00Z'
$datetime = new DateTime('2020-07-26 20:00:00', new
DateTimeZone('Europe/London'));
$datetime->format('Y-m-d\TH:i:sP'); // '2020-07-26T20:00:00+00:00'
$datetime->format('Y-m-d\TH:i:sp'); // '2020-07-26T20:00:00+00:00'
$datetime = new DateTime('2020-07-26 20:00:00', new
DateTimeZone('Europe/Berlin'));
$datetime->format('Y-m-d\TH:i:sP'); // '2020-07-26T20:00:00+02:00'
$datetime->format('Y-m-d\TH:i:sp'); // '2020-07-26T20:00:00+02:00'
--
Edit bug report at https://bugs.php.net/bug.php?id=79903&edit=1
--
Fix committed: https://bugs.php.net/fix.php?id=79903&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=79903&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=79903&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=79903&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=79903&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=79903&r=support
Expected behavior: https://bugs.php.net/fix.php?id=79903&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=79903&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=79903&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=79903&r=globals
PHP version support discontinued: https://bugs.php.net/fix.php?id=79903&r=phptooold
Daylight Savings: https://bugs.php.net/fix.php?id=79903&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=79903&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=79903&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=79903&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=79903&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=79903&r=mysqlcfg