Bug #74006 [Com]: fractional seconds support missing

From: Date: Fri, 21 Apr 2017 19:04:01 +0000
Subject: Bug #74006 [Com]: fractional seconds support missing
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-208708@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=74006&edit=1 ID: 74006 Comment by: robert dot reinhard at bukwild dot com Reported by: smithlmk at gmail dot com Summary: fractional seconds support missing Status: Open Type: Bug Package: PDO MySQL Operating System: windows 7 PHP Version: 7 Block user comment: N Private report: N New Comment: Yes, I am experiencing in 7.0.13 Previous Comments: ------------------------------------------------------------------------ [2017-02-01 13:30:48] andrew dot nester dot dev at gmail dot com I was trying to reproduce your issue on latest 7.0 and 7.1 versions - looks like it's working, could you please retest it on latest versions? ------------------------------------------------------------------------ [2017-01-27 10:38:30] smithlmk at gmail dot com Updated PHP version, as this bug goes all the way up to PHP 7. ------------------------------------------------------------------------ [2017-01-27 09:12:38] smithlmk at gmail dot com Description: ------------ Fractional seconds are supported in MySQL DateTime(x) field types. Writing such fields with fractional seconds via PDO into MySQL database is fully supported, however reading such fields directly via PDO won't return fractional seconds. A clumsy workaround is to wrap every DateTime field with a CONCAT function as shown in below test. Test script: --------------- (1) Create this table in MySQL: CREATE TABLE test ( id int(11) NOT NULL, dt datetime(3) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8; (2) Connect db via PDO and do this: $pdo->query("REPLACE INTO test (id, dt) VALUES (1, '2017-1-1 12:30:00.123')"); $a = $pdo->query("SELECT dt FROM test WHERE id = '1'")->fetch(); $b = $pdo->query("SELECT CONCAT(dt) AS dt FROM test WHERE id = '1'")->fetch(); var_dump($a, $b); Expected result: ---------------- array(1) { 'dt' => string(23) "2017-01-01 12:30:00.123" } array(1) { 'dt' => string(23) "2017-01-01 12:30:00.123" } Actual result: -------------- array(1) { 'dt' => string(19) "2017-01-01 12:30:00" } array(1) { 'dt' => string(23) "2017-01-01 12:30:00.123" } ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=74006&edit=1

« previous php.bugs (#208708) next »