setDate, setISODate, setTime works wrong when DateTime created from timestamp
| Bug #52290 | setDate, setISODate, setTime works wrong when DateTime created from timestamp | |||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Submitted: | 2010-07-08 15:29 UTC | Modified: | 2011-01-30 11:18 UTC |
|
||||||||||
| From: | danikas2k2 at gmail dot com | Assigned: | derick (profile) | |||||||||||
| Status: | Closed | Package: | Date/time related | |||||||||||
| PHP Version: | 5.3.2 | OS: | WinXP x86 | |||||||||||
| Private report: | No | CVE-ID: | None | |||||||||||
[2010-07-08 15:29 UTC] danikas2k2 at gmail dot com
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
Patches
Pull Requests
History
AllCommentsChangesGit/SVN commits
[2010-07-10 16:33 UTC] felipe@php.net
-Status: Open +Status: Assigned -Assigned To: +Assigned To: derick
[2011-01-30 11:18 UTC] stas@php.net
-Status: Assigned +Status: Closed
[2011-01-30 11:18 UTC] stas@php.net