Bug #52143 [NEW]: strtotime() unexpectedly changed from 5.2.13 to 5.3.2 breaking alot of scripts

From: Date: Tue, 22 Jun 2010 11:01:39 +0000
Subject: Bug #52143 [NEW]: strtotime() unexpectedly changed from 5.2.13 to 5.3.2 breaking alot of scripts
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-151762@lists.php.net to get a copy of this message
From:             
Operating system: CentOS 5.5 x86_64
PHP version:      5.3.2
Package:          Date/time related
Bug Type:         Bug
Bug description:strtotime() unexpectedly changed from 5.2.13 to 5.3.2 breaking alot of scripts

Description:
------------
In version 5.2.13 the following code:
<?php
echo ($now = strtotime('+1 day')) . ' - ' . date('d-m-Y H.i.s', $now)
.
"\n";
echo ($last = strtotime('last week', $now)) . ' - ' . date('d-m-Y
H.i.s',
$last) . "\n";
echo ($next = strtotime('+1 week', $last)) . ' - ' . date('d-m-Y
H.i.s',
$next) . "\n";
?>

Gives the following result:
1277283067 - 23-06-2010 09.51.07
1276678267 - 16-06-2010 09.51.07
1277283067 - 23-06-2010 09.51.07

That is, first line is current time.
Second time is "last week", otherwise known as "-1 week".
Third time is "+1 week", which reverses the change that the "-1 week" did.

However, this changed in 5.3.2 and it now gives the following result:
1277281904 - 23-06-2010 09.31.44
1276504304 - 14-06-2010 09.31.44
1277109104 - 21-06-2010 09.31.44

So it appears "last week" is no longer the equivalent of "-1 week".

Is this a deliberate change or something that was broken in 5.3.2?

I have been unable to test other versions and can only give you the
difference from 5.2.13 and 5.3.2.

Thanks.

Test script:
---------------
<?php
echo ($now = strtotime('+1 day')) . ' - ' . date('d-m-Y H.i.s', $now)
.
"\n";
echo ($last = strtotime('last week', $now)) . ' - ' . date('d-m-Y
H.i.s',
$last) . "\n";
echo ($next = strtotime('+1 week', $last)) . ' - ' . date('d-m-Y
H.i.s',
$next) . "\n";
?>

Expected result:
----------------
1277283067 - 23-06-2010 09.51.07
1276678267 - 16-06-2010 09.51.07
1277283067 - 23-06-2010 09.51.07

Actual result:
--------------
1277281904 - 23-06-2010 09.31.44
1276504304 - 14-06-2010 09.31.44
1277109104 - 21-06-2010 09.31.44

-- 
Edit bug report at http://bugs.php.net/bug.php?id=52143&edit=1
-- 
Try a snapshot (PHP 5.2):            http://bugs.php.net/fix.php?id=52143&r=trysnapshot52
Try a snapshot (PHP 5.3):            http://bugs.php.net/fix.php?id=52143&r=trysnapshot53
Try a snapshot (trunk):              http://bugs.php.net/fix.php?id=52143&r=trysnapshottrunk
Fixed in SVN:                        http://bugs.php.net/fix.php?id=52143&r=fixed
Fixed in SVN and need be documented: http://bugs.php.net/fix.php?id=52143&r=needdocs
Fixed in release:                    http://bugs.php.net/fix.php?id=52143&r=alreadyfixed
Need backtrace:                      http://bugs.php.net/fix.php?id=52143&r=needtrace
Need Reproduce Script:               http://bugs.php.net/fix.php?id=52143&r=needscript
Try newer version:                   http://bugs.php.net/fix.php?id=52143&r=oldversion
Not developer issue:                 http://bugs.php.net/fix.php?id=52143&r=support
Expected behavior:                   http://bugs.php.net/fix.php?id=52143&r=notwrong
Not enough info:                     http://bugs.php.net/fix.php?id=52143&r=notenoughinfo
Submitted twice:                     http://bugs.php.net/fix.php?id=52143&r=submittedtwice
register_globals:                    http://bugs.php.net/fix.php?id=52143&r=globals
PHP 4 support discontinued:          http://bugs.php.net/fix.php?id=52143&r=php4
Daylight Savings:                    http://bugs.php.net/fix.php?id=52143&r=dst
IIS Stability:                       http://bugs.php.net/fix.php?id=52143&r=isapi
Install GNU Sed:                     http://bugs.php.net/fix.php?id=52143&r=gnused
Floating point limitations:          http://bugs.php.net/fix.php?id=52143&r=float
No Zend Extensions:                  http://bugs.php.net/fix.php?id=52143&r=nozend
MySQL Configuration Error:           http://bugs.php.net/fix.php?id=52143&r=mysqlcfg



Thread (5 messages)

« previous php.bugs (#151762) next »