Bug #67308 [NEW]: Serialize of DateTime truncates fractions of second

From: Date: Tue, 20 May 2014 10:19:17 +0000
Subject: Bug #67308 [NEW]: Serialize of DateTime truncates fractions of second
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-185871@lists.php.net to get a copy of this message
From: robert dot johnson at icap dot com Operating system: XP sp3 PHP version: 5.4.28 Package: Date/time related Bug Type: Bug Bug description:Serialize of DateTime truncates fractions of second 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 bug report at https://bugs.php.net/bug.php?id=67308&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=67308&r=trysnapshot54 Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=67308&r=trysnapshot55 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=67308&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=67308&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=67308&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=67308&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=67308&r=needscript Try newer version: https://bugs.php.net/fix.php?id=67308&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=67308&r=support Expected behavior: https://bugs.php.net/fix.php?id=67308&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=67308&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=67308&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=67308&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=67308&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=67308&r=dst IIS Stability: https://bugs.php.net/fix.php?id=67308&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=67308&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=67308&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=67308&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=67308&r=mysqlcfg

« previous php.bugs (#185871) next »