ID: 43452 Comment by: soapergem at gmail dot com Reported By: sean dot thorne at gmail dot com Status: Open Bug Type: Date/time related Operating System: Mac OS X 10.4.11 PHP Version: 5.2CVS-2007-11-29 (CVS) New Comment:
I also confirmed this. This is pretty serious, too! There are an infinite number of examples in which you can reproduce it; here are a few: // expect 06-15-2008, get 06-22-2008 $date = strtotime('3 Sunday June 2008'); echo date('m-d-Y', $date); // expect 07-08-2008, get 07-15-2008 $date = strtotime('2 Tuesday July 2008'); echo date('m-d-Y', $date); // expect 08-22-2008, get 08-29-2008 $date = strtotime('4 Friday August 2008'); echo date('m-d-Y', $date); // expect 09-29-2008, get 10-06-2008 $date = strtotime('5 Monday September 2008'); echo date('m-d-Y', $date); // expect 10-01-2008, get 10-08-2008 $date = strtotime('1 Wednesday October 2008'); echo date('m-d-Y', $date); Developers please take note: THIS IS A SERIOUS BUG! (and it's been around for a long time) Previous Comments: ------------------------------------------------------------------------ [2008-04-02 14:06:23] billyt at claritytech dot com We also wrote our own function that handles it. Although, it's purely by random chance that we discovered the problem. It's not something we would specifically have tested for. I wonder how many other people are using it in production with no idea that it's a problem. ------------------------------------------------------------------------ [2008-03-30 22:39:34] sean dot thorne at gmail dot com I ended up writing a compensator for the problem, because it appears that the PHP Dev crew has better things to do then clean up the code base... I kept it simple and grabbed what day was the the first of the month and then found where Thursday would be in comparison and knew the third thursday was just 3 times whatever the date of the first thursday. ------------------------------------------------------------------------ [2008-03-30 22:21:21] billyt at claritytech dot com This is still a problem with 5.2.6RC4-dev!!! This is causing us serious issues ... any ideas??? ------------------------------------------------------------------------ [2007-11-29 15:39:52] sean dot thorne at gmail dot com Description: ------------ When asking strtotime for the 3rd thursday in a month and the first day of that month is thursday, it ignores the first thursday. It then begins to count after that first Thursday and returns the fourth Thursday. Reproduce code: --------------- $day = strtotime("3 Thursday Nov 2007"); echo date("m-d-Y", $day); Expected result: ---------------- 11-15-2007 Actual result: -------------- 11-22-2007 ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=43452&edit=1