ID:               48291
 Updated by:       [email protected]
 Reported By:      rob at guidamedia dot com
-Status:           Open
+Status:           Bogus
 Bug Type:         Scripting Engine problem
 Operating System: iis
 PHP Version:      5.2.9
 New Comment:

Please do not submit the same bug more than once. An existing
bug report already describes this very problem. Even if you feel
that your issue is somewhat different, the resolution is likely
to be the same. 

Thank you for your interest in PHP.




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

[2009-05-15 11:01:22] rob at guidamedia dot com

Description:
------------
When converting weeks and days to a date using strtotime, some months
return the wrong dates. For instance, strtotime("first thursday",
mktime(0,0,0,11,1,2009)) returns 11/4/2009, which is a wednesday. There
are also issues using "last".

This seems to be happening with November 2009. I am not sure about
other years or other months. I think I had issues there as well, but
infrequently. I tried seeing if the issue is with any month when the
first day of the month is sunday, but it does not appear to be the
case.

I am creating a new function to handle strtotime in this manner,
because I found more issues with using this function and creating a
series of dates that are incremented by a year.


Reproduce code:
---------------
public function getDateFromWeekAndDayOfMonth($d, $m, $y){
$fistDayOfMonth = mktime(0, 0, 0, $m, 1, $y)
$firstWeekForDay = strtotime("first " . $d, $fistDayOfMonth);
return $firstWeekForDay;
}


Expected result:
----------------
For the First Thursday in November 1, 2009, I expect to have the
datetime for 11-5-2009.

Actual result:
--------------
11-4-2009


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


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

Reply via email to