Bug #75745 [NEW]: DateTime::createFromFormat "u" specifier not interpreted correctly
| From: | daverandom@php.net | Date: | Thu, 28 Dec 2017 20:36:06 +0000 |
| Subject: | Bug #75745 [NEW]: DateTime::createFromFormat "u" specifier not interpreted correctly | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-213317@lists.php.net to get a copy of this message | ||
From: daverandom
Operating system: Any
PHP version: 7.1.12
Package: Date/time related
Bug Type: Bug
Bug description:DateTime::createFromFormat "u" specifier not interpreted correctly
Description:
------------
The "u" specifier is documented as "microseconds" but is interpreted as
"fraction of a second".
While this is not the correct behaviour, it is potentially a desirable
behaviour, specifically one might expect to be able to interpret a date
like
12:13:14.42 as having a fractional part.
I propose adding an "f" specifier (currently unused) which retains this
old behaviour, and fixing "u" to work as documented.
Test script:
---------------
echo DateTime::createFromFormat('u', '42')->format('u');
Expected result:
----------------
000042
Actual result:
--------------
420000
--
Edit bug report at https://bugs.php.net/bug.php?id=75745&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=75745&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=75745&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=75745&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=75745&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=75745&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=75745&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=75745&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=75745&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=75745&r=support
Expected behavior: https://bugs.php.net/fix.php?id=75745&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=75745&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=75745&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=75745&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=75745&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=75745&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=75745&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=75745&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=75745&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=75745&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=75745&r=mysqlcfg