From:
Operating system: Linux 2.6.36-hardened
PHP version: 5.3.6
Package: Date/time related
Bug Type: Bug
Bug description:strtotime(): "this week" gives incorrect result for Sunday dates
Description:
------------
When trying to get relative dates, strtotime() gives incorrect result for
relative format "{weekday} this week" when the base date is Sunday. It
should return the same day, as it does with other weekdays, but it returns
next week's day.
Test script:
---------------
<?php
error_reporting( -1 );
date_default_timezone_set( "Europe/Bratislava" );
for ( $i = 0; $i < 7; $i++ )
{
$base = strtotime( "2011/01/17 +$i days 12:00:00" );
$weekday = date( "l", $base );
$relative = strtotime( "$weekday this week 12:00:00", $base );
echo date( "l Y/m/d", $base ), "\n", date( "l Y/m/d", $relative ),
"\n\n";
}
?>
Expected result:
----------------
Monday 2011/01/17
Monday 2011/01/17
Tuesday 2011/01/18
Tuesday 2011/01/18
Wednesday 2011/01/19
Wednesday 2011/01/19
Thursday 2011/01/20
Thursday 2011/01/20
Friday 2011/01/21
Friday 2011/01/21
Saturday 2011/01/22
Saturday 2011/01/22
Sunday 2011/01/23
Sunday 2011/01/23
Actual result:
--------------
Monday 2011/01/17
Monday 2011/01/17
Tuesday 2011/01/18
Tuesday 2011/01/18
Wednesday 2011/01/19
Wednesday 2011/01/19
Thursday 2011/01/20
Thursday 2011/01/20
Friday 2011/01/21
Friday 2011/01/21
Saturday 2011/01/22
Saturday 2011/01/22
Sunday 2011/01/23
Sunday 2011/01/30
--
Edit bug report at http://bugs.php.net/bug.php?id=54409&edit=1
--
Try a snapshot (PHP 5.2):
http://bugs.php.net/fix.php?id=54409&r=trysnapshot52
Try a snapshot (PHP 5.3):
http://bugs.php.net/fix.php?id=54409&r=trysnapshot53
Try a snapshot (trunk):
http://bugs.php.net/fix.php?id=54409&r=trysnapshottrunk
Fixed in SVN:
http://bugs.php.net/fix.php?id=54409&r=fixed
Fixed in SVN and need be documented:
http://bugs.php.net/fix.php?id=54409&r=needdocs
Fixed in release:
http://bugs.php.net/fix.php?id=54409&r=alreadyfixed
Need backtrace:
http://bugs.php.net/fix.php?id=54409&r=needtrace
Need Reproduce Script:
http://bugs.php.net/fix.php?id=54409&r=needscript
Try newer version:
http://bugs.php.net/fix.php?id=54409&r=oldversion
Not developer issue:
http://bugs.php.net/fix.php?id=54409&r=support
Expected behavior:
http://bugs.php.net/fix.php?id=54409&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=54409&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=54409&r=submittedtwice
register_globals:
http://bugs.php.net/fix.php?id=54409&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=54409&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=54409&r=dst
IIS Stability:
http://bugs.php.net/fix.php?id=54409&r=isapi
Install GNU Sed:
http://bugs.php.net/fix.php?id=54409&r=gnused
Floating point limitations:
http://bugs.php.net/fix.php?id=54409&r=float
No Zend Extensions:
http://bugs.php.net/fix.php?id=54409&r=nozend
MySQL Configuration Error:
http://bugs.php.net/fix.php?id=54409&r=mysqlcfg