#39821 [Opn->Bgs]: Unable to Serialize and then Unserialize a PHP DateTime Object

From: Date: Sun, 17 Dec 2006 14:25:14 +0000
Subject: #39821 [Opn->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-106438@lists.php.net to get a copy of this message
 ID:               39821
 Updated by:       bjori@php.net
 Reported By:      php at michaelho dot com
-Status:           Open
+Status:           Bogus
 Bug Type:         Date/time related
 Operating System: Mac OS X 10.4.7
 PHP Version:      5.2.0
 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

From www.php.net/serialize: "It is not possible to 
serialize PHP built-in objects."


Previous Comments:
------------------------------------------------------------------------

[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


Thread (3 messages)

« previous php.bugs (#106438) next »