Edit report at https://bugs.php.net/bug.php?id=55015&edit=1
ID: 55015 Comment by: lonnyk at gmail dot com Reported by: cp at ltur dot de Summary: strToTime calculates wrong date Status: Wont fix Type: Bug Package: Date/time related Operating System: Linux PHP Version: 5.3.6 Block user comment: N Private report: N New Comment: Hi, I do not know if it matters, but this bug was created when the order was changed in rev #213026 Previous Comments: ------------------------------------------------------------------------ [2011-07-06 05:47:18] cp at ltur dot de Hi Derick, > We can't just randomly change the order because other people may rely on it. I understand this, but it is still a bug. It should be mentioned in the strToTime() documentation along with the workaround you posted, so people use the function with care. kind regards .cp ------------------------------------------------------------------------ [2011-07-06 05:01:13] der...@php.net We can't just randomly change the order because other people may rely on it. What you want to do is really this: $date = date_create("2011-06-09 00:00:00")->modify("next month")->modify("next monday"); ------------------------------------------------------------------------ [2011-07-06 03:41:37] cp at ltur dot de Hi, i applied the patch from lonny and it works for me :-) php > date_default_timezone_set('Europe/Berlin'); php > echo date('Ymd N', strToTime('next month next Monday', mktime(0,0,0,6,9,2011))); // prints 20110711 1 Will somebody commit his patch? kind regards .cp ------------------------------------------------------------------------ [2011-07-06 02:10:07] lonnyk at gmail dot com The problem is that the relative weekday was calculated before the relative month/year. I attached a batch and a test to change the order of the calculation. ------------------------------------------------------------------------ [2011-07-01 04:52:27] lonnyk at gmail dot com I also found that if you are using this code and the next Monday is in the next month then the month will advance two months. I set the date to 20110630 and ran the exact same test script: lonny@lonnydev:~/php/php-src-5.3$ sudo date -s "30 JUN 2011 10:00:00" Thu Jun 30 10:00:00 EDT 2011 lonny@lonnydev:~/php/php-src-5.3$ php ~/test.php 20110804 4 ------------------------------------------------------------------------ The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at https://bugs.php.net/bug.php?id=55015 -- Edit this bug report at https://bugs.php.net/bug.php?id=55015&edit=1