Bug #75745 [Opn->Csd]: DateTime::createFromFormat "u" specifier not interpreted correctly

From: Date: Wed, 08 Jun 2022 14:59:35 +0000
Subject: Bug #75745 [Opn->Csd]: DateTime::createFromFormat "u" specifier not interpreted correctly
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-241688@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=75745&edit=1 ID: 75745 Updated by: git@php.net Reported by: daverandom@php.net Summary: DateTime::createFromFormat "u" specifier not interpreted correctly -Status: Open +Status: Closed Type: Bug Package: Date/time related Operating System: Any PHP Version: >=7.1.0 Block user comment: N Private report: N New Comment: Automatic comment on behalf of derickr Revision: https://github.com/php/doc-en/commit/084a0039f62c982526dc7e4334f526b31ce2ff63 Log: Fixed bug #75745: DateTime::createFromFormat 'u' specifier not documented correctly Previous Comments: ------------------------------------------------------------------------ [2020-04-11 15:22:00] cmb@php.net FWIW, the the v specifier (milliseconds) available as of PHP 7.3.0 behaves in the same way. ------------------------------------------------------------------------ [2017-12-28 20:36:05] daverandom@php.net 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 this bug report at https://bugs.php.net/bug.php?id=75745&edit=1

« previous php.bugs (#241688) next »