ID: 46641 Updated by: [EMAIL PROTECTED] Reported By: cross+php at distal dot com -Status: Verified +Status: Bogus Bug Type: Date/time related Operating System: * PHP Version: 5CVS, 6CVS (2008-11-21) 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 This is expected. Without converting to an integer with strtotime(), the DateTime object remembers which timezone it was created with. In this case the timezone it knows is "GMT-0500". If you use date(), this information is not available and it will use the default timezone. The following example shows this a bit better: [EMAIL PROTECTED]:/tmp$ cat bug46641.php <?php date_default_timezone_set('Europe/Oslo'); $timestr = "2008-11-19 10:51:35.199665-05"; $outformat = "M j Y H:i:s T (e,I,O,P,T,Z)"; $obj = new DateTime($timestr); print date($outformat, strtotime($timestr)) . "\n"; print $obj->format($outformat) . "\n"; ?> [EMAIL PROTECTED]:/tmp$ php bug46641.php Nov 19 2008 16:51:35 CET (Europe/Oslo,0,+0100,+01:00,CET,3600) Nov 19 2008 10:51:35 GMT-0500 (-05:00,0,-0500,-05:00,GMT-0500,-18000) Previous Comments: ------------------------------------------------------------------------ [2008-11-21 17:46:13] cross+php at distal dot com Description: ------------ When using some of the timezone output format characters, notably "e" and "T", produce different results on a DateTime built from a string time and calling date() on the results of strtotime(). Reproduce code: --------------- <?php $timestr = "2008-11-19 10:51:35.199665-05"; $outformat = "M j Y H:i:s T (e,I,O,P,T,Z)"; $obj = new DateTime($timestr); print date($outformat, strtotime($timestr)) . "\n"; print $obj->format($outformat) . "\n"; ?> Expected result: ---------------- Nov 19 2008 10:51:35 EST (America/New_York,0,-0500,-05:00,EST,-18000) Nov 19 2008 10:51:35 EST (America/New_York,0,-0500,-05:00,EST,-18000) Actual result: -------------- Nov 19 2008 10:51:35 EST (America/New_York,0,-0500,-05:00,EST,-18000) Nov 19 2008 10:51:35 GMT-0500 (-05:00,0,-0500,-05:00,GMT-0500,-18000) ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=46641&edit=1
