Bug #67308 [Opn->Csd]: Serialize of DateTime truncates fractions of second
| From: | aharvey@php.net | Date: | Wed, 21 May 2014 20:07:08 +0000 |
| Subject: | Bug #67308 [Opn->Csd]: Serialize of DateTime truncates fractions of second | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-185888@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=67308&edit=1
ID: 67308
Updated by: aharvey@php.net
Reported by: robert dot johnson at icap dot com
Summary: Serialize of DateTime truncates fractions of second
-Status: Open
+Status: Closed
Type: Bug
Package: Date/time related
Operating System: XP sp3
PHP Version: 5.4.28
-Assigned To:
+Assigned To: aharvey
Block user comment: N
Private report: N
New Comment:
The fix for this bug has been committed.
Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
For Windows:
http://windows.php.net/snapshots/
Thank you for the report, and for helping us make PHP better.
Previous Comments:
------------------------------------------------------------------------
[2014-05-20 10:19:16] robert dot johnson at icap dot com
Description:
------------
DateTime fractions of a second are ignored when serialized.
A DateTime cannot be correctly serialized and unserialized.
Test script:
---------------
$floatTime = '1400580590.47359';
$nowtime = \DateTime::createFromFormat('U.u', $floatTime);
echo $nowtime->format('Y-m-d H:i:s.u T')."\r\n";
echo serialize($nowtime)."\r\n";
Expected result:
----------------
2014-05-20 10:09:50.473590 GMT+0000
O:8:"DateTime":3:{s:4:"date";s:19:"2014-05-20
10:09:50.473590";s:13:"timezone_type";i:1;s:8:"timezone";s:6:"+00:00";}
/*
Note: this serialized DateTime includes the fraction, and when it is passed to unserialize(), the
fraction is correctly set in the resulting DateTime object.
Therefore unserialize() works, serialize() does not work.
*/
Actual result:
--------------
2014-05-20 10:09:50.473590 GMT+0000
O:8:"DateTime":3:{s:4:"date";s:19:"2014-05-20
10:09:50";s:13:"timezone_type";i:1;s:8:"timezone";s:6:"+00:00";}
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=67308&edit=1