php 5.3.2 is affected by a bug in the DateTime object

Bug #805206 reported by Francesco Lamonica
14
This bug affects 2 people
Affects Status Importance Assigned to Milestone
php5 (Ubuntu)
Confirmed
Medium
Unassigned

Bug Description

there is a bug in ubuntu 10.04 (both 32 and 64 bits) php5-common package.

the following code shows the problem:

<?php
$nstartDate = new DateTime();
$nendDate = new DateTime();
print("<br/>0:" . $nstartDate->format("Y-m-d")); //this prints 3 months ago

$nstartDate->sub(new DateInterval("P1M"));

print("<br/>1:" . $nstartDate->format("Y-m-d")); //this prints 3 months ago

$nstartDate->getTimestamp();
print("<br/>2:" . $nstartDate->format("Y-m-d")); //this prints 3 months ago

$nstartDate->getTimestamp();
print("<br/>3:" . $nstartDate->format("Y-m-d")); //this prints 3 months ago

?>

as you will see, each time getTimestamp() is called the date is subtracted by one month (instead of just once) no other distro seems to be affectd nor php 5.3.3.

Please update it as soon as possible. This is a serious bug in php code.

Tags: datetime php
Revision history for this message
Dave Walker (davewalker) wrote :

Thanks for reporting this issue.

Setting importance to Medium as this could potentially cause a serious issue. For this issue to progress, a minimal patch needs to be identified that resolves this issue.

Thanks.

Changed in php5 (Ubuntu):
importance: Undecided → Medium
status: New → Confirmed
Revision history for this message
Alex Greenshot (mail2lx) wrote :

This bug also affects us. but only on 10.04, not on a similar machine with 12.04.

This is a very severe issue for us, as we are running a booking platform, and wrong time offsets cause erroneous bookings.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.