php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
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
Votes:1
Avg. Score:3.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
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 commitsRelated reports
 [2010-07-10 16:33 UTC] felipe@php.net
-Status: Open +Status: Assigned -Assigned To: +Assigned To: derick
 [2010-07-17 23:57 UTC] k.schroeder@php.net
Automatic comment from SVN on behalf of k.schroeder
Revision: http://svn.php.net/viewvc/?view=revision&revision=301357
Log: Test for #52290
 [2011-01-30 11:18 UTC] stas@php.net
Automatic comment from SVN on behalf of stas
Revision: http://svn.php.net/viewvc/?view=revision&revision=307853
Log: Fix bug #52290 (setDate, setISODate, setTime works wrong when DateTime created from timestamp)
 [2011-01-30 11:18 UTC] stas@php.net
-Status: Assigned +Status: Closed
 [2011-01-30 11:18 UTC] stas@php.net
This bug has been fixed in SVN.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Dec 03 17:01:29 2024 UTC