Bug #54409 [Opn->Asn]: strtotime(): "this week" gives incorrect result for Sunday dates
| From: | derick@php.net | Date: | Mon, 28 Mar 2011 19:06:24 +0000 |
| Subject: | Bug #54409 [Opn->Asn]: strtotime(): "this week" gives incorrect result for Sunday dates | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-159819@lists.php.net to get a copy of this message | ||
Edit report at http://bugs.php.net/bug.php?id=54409&edit=1
ID: 54409
Updated by: derick@php.net
Reported by: 1234 dot ia at gmail dot com
Summary: strtotime(): "this week" gives incorrect result for
Sunday dates
-Status: Open
+Status: Assigned
Type: Bug
Package: Date/time related
Operating System: Linux 2.6.36-hardened
PHP Version: 5.3.6
-Assigned To:
+Assigned To: derick
Block user comment: N
Private report: N
Previous Comments:
------------------------------------------------------------------------
[2011-03-28 17:20:20] 1234 dot ia at gmail dot com
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 this bug report at http://bugs.php.net/bug.php?id=54409&edit=1