ID:               49981
 User updated by:  shokarta at gmail dot com
 Reported By:      shokarta at gmail dot com
 Status:           Bogus
 Bug Type:         Date/time related
 Operating System: WinXP SP2/AppServ2.5.9
 PHP Version:      5.2SVN-2009-10-24 (snap)
 New Comment:

for example try this:
use date 1st of April 2009 (its wednesday).

echo date("j.m.Y",strtotime("last Monday",strtotime("04/01/2009"))); 
// RESULT is 30.03.2009 (should be 23.03.2009)
echo date("j.m.Y",strtotime("this Monday",strtotime("04/01/2009"))); 
// RESULT is 06.04.2009 (should be 30.04.2009)
echo date("j.m.Y",strtotime("next Monday",strtotime("04/01/2009"))); 
// RESULT is 06.04.2009 (should be 06.04.2009) - CORRECT

just found out that "this" doesnt work or works only as itself wants.

if i accidently jump on timestamp which stands for any Monday, then 
"last Monday" should show 1 week ago, "this monday" should show this 
day, "next monday" should show 1 week later!

but it wont show like this!

another example:

$month_min = strtotime("2009-01-01");
  for($i=0; $i<12; $i++)
   {
    $month = strtotime("+$i months",$month_min);
    $month = strtotime("last Monday",$month); }
    echo date("d.m.Y",$month)."<br>";
   }
  unset($i);

once u load the page then change code from "last Monday" to "this 
Monday" and once you reload only some of them will change! (and 
sometimes when you cange it back to "last Monday" and reload again 
then some of the others will change even when they didnt change 
before!

still not a bug?


Previous Comments:
------------------------------------------------------------------------

[2009-10-24 21:03:19] sni...@php.net

Check your timezone. Always use gmdate() to not get such surprises.
There is no bug here.

------------------------------------------------------------------------

[2009-10-24 00:40:50] shokarta at gmail dot com

can make it works like this:
$actual_week = date("Y\WW",1319281200);
$real_result = strtotime("this monday",strtotime($actual_week));
but its only for this specific error

------------------------------------------------------------------------

[2009-10-24 00:20:30] shokarta at gmail dot com

Description:
------------
Got a timestamp for sunday 1319281200 (its Sunday 23.10.2011),
date("W") 
says its 42nd week of the year.

if i do strtotime("this monday",1319281200) then it will return: 
1319367600 which is monday 24.10.2011 and date("W") says its 43rd week

on that year..

so simply strtotime works that sunday is a first day in a week instead

of date which makes monday as a first day...

can i configure strtotime to work on monday as a first day as well?

Reproduce code:
---------------
strtotime("this monday",1319281200);

Expected result:
----------------
1318762800 (week 42, monday, 17/10/2011)

Actual result:
--------------
1319367600 (week 43, sunday, 24/10/2011)


------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=49981&edit=1

Reply via email to