php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #52342 DateTime setIsoDate results in wrong timestamp
Submitted: 2010-07-15 08:41 UTC Modified: 2010-08-30 18:48 UTC
From: freund at lotum dot de Assigned: derick (profile)
Status: Closed Package: Date/time related
PHP Version: 5.3.2 OS: Debian Lenny
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: freund at lotum dot de
New email:
PHP Version: OS:

 

 [2010-07-15 08:41 UTC] freund at lotum dot de
Description:
------------
Try to get Midnight of the first Weekday of a Weeknumber of a specific year:

$from = new DateTime();
$from->setTime(0, 0, 0);
$from->setISODate(2010, 28, 1); //Montag der 28ten Woche 2010
 
echo $from->format('d.m.Y H:i'); //A
echo $from->getTimestamp(); //B
echo date('Y-m-d H:i', $from->getTimestamp()); //C

The result is as expected, after adding an interval of 0 Days:
$from->add(new DateInterval('P0D'));

Expected result:
----------------
12.07.2010
1278885600
12.07.2010 00:00

Actual result:
--------------
12.07.2010
1291849200
29.05.2011 00:00

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-07-18 20:21 UTC] felipe@php.net
-Status: Open +Status: Assigned -Assigned To: +Assigned To: derick
 [2010-08-30 18:48 UTC] derick@php.net
Automatic comment from SVN on behalf of derick
Revision: http://svn.php.net/viewvc/?view=revision&revision=302893
Log: - Tests for bug #52342 (DateTime setIsoDate results in wrong timestamp).
 [2010-08-30 18:48 UTC] derick@php.net
-Status: Assigned +Status: Closed
 [2010-08-30 18:48 UTC] derick@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.

I think this is already fixed in SVN (I can reproduce this issue with 5.3.3 but not with 5.3.4-dev and 5.3.99-dev).
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon Apr 29 08:01:29 2024 UTC