php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #52142 using diff change the datetime object
Submitted: 2010-06-22 12:40 UTC Modified: 2011-12-06 06:14 UTC
Votes:7
Avg. Score:3.7 ± 0.7
Reproduced:5 of 5 (100.0%)
Same Version:3 (60.0%)
Same OS:2 (40.0%)
From: riccardo at mercuriosistemi dot com Assigned: derick (profile)
Status: Closed Package: Date/time related
PHP Version: 5.3.2 OS: slackware
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 you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: riccardo at mercuriosistemi dot com
New email:
PHP Version: OS:

 

 [2010-06-22 12:40 UTC] riccardo at mercuriosistemi dot com
Description:
------------
A DateTime object with timezone_type=1 is always set to timezone=+00:00 after the use of diff

Test script:
---------------
date_default_timezone_set( "Europe/Rome" );

$da = new DateTime('2010-06-22T00:00:00+02:00');
$a = new DateTime('2010/06/23');

print_r($da);

$da->diff($a);
// $da has been changed
print_r($da);

Expected result:
----------------
DateTime Object
(
    [date] => 2010-06-22 00:00:00
    [timezone_type] => 1
    [timezone] => +02:00
)
DateTime Object
(
    [date] => 2010-06-21 22:00:00
    [timezone_type] => 1
    [timezone] => +02:00
)


Actual result:
--------------
DateTime Object
(
    [date] => 2010-06-22 00:00:00
    [timezone_type] => 1
    [timezone] => +02:00
)
DateTime Object
(
    [date] => 2010-06-21 22:00:00
    [timezone_type] => 1
    [timezone] => +00:00
)


Patches

bug52142-fix_interval.c.patch (last revision 2010-08-15 21:18 UTC by strager dot nds at gmail dot com)
bug52142.phpt (last revision 2010-08-15 21:18 UTC by strager dot nds at gmail dot com)

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-06-22 15:38 UTC] tony2001@php.net
-Status: Open +Status: Assigned -Assigned To: +Assigned To: derick
 [2010-08-15 23:19 UTC] strager dot nds at gmail dot com
Wrote a test case and a fix for this bug.  See attached patches.
 [2010-08-15 23:20 UTC] strager dot nds at gmail dot com
Eh, also, this is from the 5.3.3 release of PHP.  Tested on:

Linux strager-desktop 2.6.32-21-generic #32-Ubuntu SMP Fri Apr 16 08:10:02 UTC 2010 i686 GNU/Linux
 [2011-12-06 06:14 UTC] derick@php.net
Thank you for your bug report. This issue has already been fixed
in the latest released version of PHP, which you can download at 
http://www.php.net/downloads.php

Somebody had applied this patch already, so closing.
 [2011-12-06 06:14 UTC] derick@php.net
-Status: Assigned +Status: Closed
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Fri Apr 11 15:01:30 2025 UTC