Bug #51234 [Opn->Bgs]: echo $dt->date doesn't work unless preceeded by print_r($dt)
| From: | derick@php.net | Date: | Mon, 08 Mar 2010 11:50:06 +0000 |
| Subject: | Bug #51234 [Opn->Bgs]: echo $dt->date doesn't work unless preceeded by print_r($dt) | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-148390@lists.php.net to get a copy of this message | ||
Edit report at http://bugs.php.net/bug.php?id=51234&edit=1
ID: 51234
Updated by: derick@php.net
Reported by: php at mpodr dot com
Summary: echo $dt->date doesn't work unless preceeded by
print_r($dt)
-Status: Open
+Status: Bogus
Type: Bug
Package: Date/time related
Operating System: CentOS 5.4
PHP Version: 5.3SVN-2010-03-08 (SVN)
New Comment:
Please do not submit the same bug more than once. An existing
bug report already describes this very problem. Even if you feel
that your issue is somewhat different, the resolution is likely
to be the same.
Thank you for your interest in PHP.
Duplicate of #49382.
Previous Comments:
------------------------------------------------------------------------
[2010-03-08 12:28:17] php at mpodr dot com
Description:
------------
This example was taken straight from the DateTime::createFromFormat page
at:
http://www.php.net/manual/en/datetime.createfromformat.php
After performing a DateTime::createFromFormat, the variable assigned
doesn't seem to work. HOWEVER, the variable assigned DOES seem to work
after being used in a print_r function.
Please look at the test script and output. What am I doing wrong?
Condensed Code Snippet:
=======================
$format = 'Y-m-d';
$dt = DateTime::createFromFormat($format, '2009-02-03');
echo "<br>Format: $format; " . $dt->date . " (Should print \"2009-02-03
[time]\")<br>";
print_r($dt);
echo "<br>Format: $format; " . $dt->date . " (Should print \"2009-02-03
[time]\")<br>";
Output:
=======
Format: Y-m-d; (Should print "2009-02-03 [time]")
DateTime Object ( [date] => 2009-02-03 06:23:24 [timezone_type] => 3
[timezone] => America/New_York )
Format: Y-m-d; 2009-02-03 06:23:24 (Should print "2009-02-03 [time]")
Test script:
---------------
Code Snippet:
=============
$format = 'Y-m-d';
$dt = DateTime::createFromFormat($format, '2009-02-03');
echo "<br>Format: $format; " . $dt->date . " (Should print \"2009-02-03
[time]\")<br>";
Output:
=======
Format: Y-m-d; (Should print "2009-02-03 [time]")
DateTime Object ( [date] => 2009-02-03 06:23:24 [timezone_type] => 3
[timezone] => America/New_York )
Format: Y-m-d; 2009-02-03 06:23:24 (Should print "2009-02-03 [time]")
Expected result:
----------------
Format: Y-m-d; 2009-02-03 06:23:24 (Should print "2009-02-03 [time]")
Actual result:
--------------
Format: Y-m-d; (Should print "2009-02-03 [time]")
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/bug.php?id=51234&edit=1