Bug #75087 [Opn->Nab]: DateTime::createFromFormat fails with float without fractional part
| From: | kelunik@php.net | Date: | Thu, 17 Aug 2017 17:04:29 +0000 |
| Subject: | Bug #75087 [Opn->Nab]: DateTime::createFromFormat fails with float without fractional part | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-210716@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=75087&edit=1
ID: 75087
Updated by: kelunik@php.net
Reported by: ronan dot giron at vigicorp dot fr
-Summary: microtime() with 0 microseconds return false
+Summary: DateTime::createFromFormat fails with float without
fractional part
-Status: Open
+Status: Not a bug
Type: Bug
Package: Date/time related
-Operating System: Windows
+Operating System:
PHP Version: 7.1.8
Block user comment: N
Private report: N
New Comment:
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to
report
a bug at http://bugs.php.net/how-to-report.php
This is expected. createFromFormat accepts a string. A float without fraction doesn't contain a
dot when transformed to a string.
Just use var_dump(\DateTime::createFromFormat('u U', microtime())); instead, which always
has a microsecond and second part.
Previous Comments:
------------------------------------------------------------------------
[2017-08-17 16:56:01] ronan dot giron at vigicorp dot fr
Description:
------------
\DateTime::createFromFormat('U.u', microtime(true))
returns false when no microseconds.
Test script:
---------------
// OK
var_dump(\DateTime::createFromFormat('U.u', 1502988140.0001));
// KO : false
var_dump(\DateTime::createFromFormat('U.u', 1502988140.0000));
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=75087&edit=1