PEAR is discontinued

This is a static archive preserving historical releases and metadata. No new packages or updates will be published. For updates to existing packages, or to publish new packages, please use Composer and Packagist.

Home » Date and Time » Date » Bug #9414

addSeconds fails to work properly with negative numbers

Details

Submitted2006-11-21 23:16 UTC
Fromkpeters at monolithss dot com
Assignedfirman
StatusClosed
PackageDate
PHP Version4.3.3
OSSuSE Linux 9.0
Roadmaps(Not assigned)

Comments

[2006-11-21 23:16 UTC] kpeters at monolithss dot com

Description:
------------
Adding a negative number of seconds to a date via addSeconds does not modify the date.

Test script:
---------------
<?php
require_once 'Date.php';
$date = new Date('2006-11-21');

print "Date is now: " . $date->format("%Y-%m-%d %H:%M") . "\n";
$date->addSeconds(-1 * 86400 * 7); # subtract 1 week
print "After subtracting a week's worth of seconds, date is: " . $date->format("%Y-%m-%d %H:%M") . "\n";

?>

Expected result:
----------------
Date should be decremented by the specified number of seconds

Actual result:
--------------
Date is unchanged.