ID: 50059 Updated by: der...@php.net Reported By: herrnoel at gmail dot com Status: Bogus Bug Type: Date/time related Operating System: Linux/Debian 5.0.3 PHP Version: 5.2.11 New Comment:
No, it is not a wrapper around anything, but it's still not a bug. There is lots of logic involved here but that belongs in the docs (and there is already an issue open for that I think). Previous Comments: ------------------------------------------------------------------------ [2009-11-03 23:01:50] herrnoel at gmail dot com 1) OK that's a sort of fair point. I'll see if I can drum up some access to a compiled install... 2) strtotime() is a wrapper to GNU's date function right? http://www.gnu.org/software/coreutils/manual/coreutils.html#Day-of-week-items I believe this is correct syntax. "A number may precede a day of the week item to move forward supplementary weeks. It is best used in expression like third monday. In this context, last day or next day is also acceptable; they move one week before or after the day that day by itself would represent. " The ordinal spellings of numbers are just aliases to integers -- I prefer the terser, numeric format. ------------------------------------------------------------------------ [2009-11-03 10:44:49] j...@php.net 1. Too old and wrong PHP version. (we only support what we release, not some badly patched binaries from 3rd party) 2. This is not a bug, strotime() is not an AI which can parse any crap you pass it. Please ask support on the right forum. ------------------------------------------------------------------------ [2009-11-03 03:19:01] herrnoel at gmail dot com Description: ------------ Actual php version is latest from debian stable: PHP 5.2.6-1+lenny3 When using strtotime() for some really handy english parsing, it works great EXCEPT for the first day of the month. The format is as follows: [1-4] [day of week] [month] [year] If the day of the week is the first day of the month, this will return the date starting one week ahead of the first day of the month. Otherwise, the behavior is as expected. This is repeatable for all months. If you leave out the initial digit, the broken first day of the month works, but then you must use 1 to indicate the 2nd instance of that day and so on. Reproduce code: --------------- echo date('Y-m-d', strtotime('1 thu oct 2009')); # first day of month echo date('Y-m-d', strtotime('1 fri oct 2009')); # second day of month echo date('Y-m-d', strtotime('1 sun nov 2009')); # first day of month echo date('Y-m-d', strtotime('2 sun nov 2009')); # second sunday of month (sunday is the first day of month) Expected result: ---------------- 2009-10-01 2009-10-02 2009-11-01 2009-11-08 Actual result: -------------- 2009-10-08 2009-10-02 2009-11-08 2009-11-15 ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=50059&edit=1