#39821 [Bgs]: Unable to Serialize and then Unserialize a PHP DateTime Object
| From: | pajoye@php.net | Date: | Tue, 10 Mar 2009 23:57:57 +0000 |
| Subject: | #39821 [Bgs]: Unable to Serialize and then Unserialize a PHP DateTime Object | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-134583@lists.php.net to get a copy of this message | ||
ID: 39821
Updated by: pajoye@php.net
Reported By: php at michaelho dot com
Status: Bogus
Bug Type: Date/time related
Operating System: Mac OS X 10.4.7
PHP Version: 5.2.0
New Comment:
Implemented in 5.3.0, see #41334
Previous Comments:
------------------------------------------------------------------------
[2006-12-17 14:25:14] bjori@php.net
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
From www.php.net/serialize: "It is not possible to
serialize PHP built-in objects."
------------------------------------------------------------------------
[2006-12-13 20:32:29] php at michaelho dot com
Description:
------------
Attempts to use a DateTime object that has been serialized/unserialized
produces an error.
Reproduce code:
---------------
<?php
$dttNow = new DateTime('now');
print $dttNow->format(DateTime::ISO8601) . '<br/>';
$strSerialized = serialize($dttNow);
$dttRestored = unserialize($strSerialized);
print $dttRestored->format(DateTime::ISO8601) . '<br/>';
?>
Expected result:
----------------
2006-12-13T12:26:39-0800
2006-12-13T12:26:39-0800
Actual result:
--------------
2006-12-13T12:26:39-0800
Warning: DateTime::format() [function.DateTime-format]: The DateTime
object has not been correctly initialized by its constructor in
/home/wcc/wwwroot/test.php on line 7
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=39821&edit=1