From:
Operating system: WinXP x86
PHP version: 5.3.2
Package: Date/time related
Bug Type: Bug
Bug description:setDate, setISODate, setTime works wrong when DateTime created
from timestamp
Description:
------------
setDate, setISODate, setTime works wrong
Test script:
---------------
$tz = 'UTC';
date_default_timezone_set($tz);
$ts = strtotime('2006-01-01');
$dt = new DateTime('@'.$ts);
$dt->setTimezone(new DateTimeZone($tz));
echo $dt->format('o-\WW-N | Y-m-d | H:i:s | U'), "\n";
$dt->setISODate(2005, 52, 1);
echo $dt->format('o-\WW-N | Y-m-d | H:i:s | U'), "\n";
$dt->setDate(2007, 10, 10);
echo $dt->format('o-\WW-N | Y-m-d | H:i:s | U'), "\n";
$dt->setTime(20, 30, 40);
echo $dt->format('o-\WW-N | Y-m-d | H:i:s | U'), "\n";
Expected result:
----------------
2005-W52-7 | 2006-01-01 | 00:00:00
2005-W52-1 | 2005-12-26 | 00:00:00
2007-W40-5 | 2007-10-10 | 00:00:00
2007-W40-5 | 2007-10-10 | 20:30:40
Actual result:
--------------
2005-W52-7 | 2006-01-01 | 00:00:00 | 1136073600
2041-W52-4 | 2041-12-26 | 00:00:00 | 2271628800
2044-W40-1 | 2044-10-03 | 00:00:00 | 2359065600
2081-W39-6 | 2081-09-27 | 20:30:40 | 3526230640
--
Edit bug report at http://bugs.php.net/bug.php?id=52290&edit=1
--
Try a snapshot (PHP 5.2):
http://bugs.php.net/fix.php?id=52290&r=trysnapshot52
Try a snapshot (PHP 5.3):
http://bugs.php.net/fix.php?id=52290&r=trysnapshot53
Try a snapshot (trunk):
http://bugs.php.net/fix.php?id=52290&r=trysnapshottrunk
Fixed in SVN:
http://bugs.php.net/fix.php?id=52290&r=fixed
Fixed in SVN and need be documented:
http://bugs.php.net/fix.php?id=52290&r=needdocs
Fixed in release:
http://bugs.php.net/fix.php?id=52290&r=alreadyfixed
Need backtrace:
http://bugs.php.net/fix.php?id=52290&r=needtrace
Need Reproduce Script:
http://bugs.php.net/fix.php?id=52290&r=needscript
Try newer version:
http://bugs.php.net/fix.php?id=52290&r=oldversion
Not developer issue:
http://bugs.php.net/fix.php?id=52290&r=support
Expected behavior:
http://bugs.php.net/fix.php?id=52290&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=52290&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=52290&r=submittedtwice
register_globals:
http://bugs.php.net/fix.php?id=52290&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=52290&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=52290&r=dst
IIS Stability:
http://bugs.php.net/fix.php?id=52290&r=isapi
Install GNU Sed:
http://bugs.php.net/fix.php?id=52290&r=gnused
Floating point limitations:
http://bugs.php.net/fix.php?id=52290&r=float
No Zend Extensions:
http://bugs.php.net/fix.php?id=52290&r=nozend
MySQL Configuration Error:
http://bugs.php.net/fix.php?id=52290&r=mysqlcfg