#43452 [Opn]: strtotime returns wrong date when requested day is same as first day of the mon

From: Date: Thu, 16 Oct 2008 23:18:40 +0000
Subject: #43452 [Opn]: strtotime returns wrong date when requested day is same as first day of the mon
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-129777@lists.php.net to get a copy of this message
ID: 43452 Updated by: till@php.net 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) Assigned To: derick New Comment: Confirmed it broken in 5.2.7-dev as well. Since it appears to be fixed in 5.3-alpha3-dev, is there any chance this fix can be backported? Previous Comments: ------------------------------------------------------------------------ [2008-10-16 22:56:28] till@php.net I had second thoughts about the "timestamp" passed into strtotime(), so I tried to create the date in a slightly different way but it failed never the less. I can also confirm this on 5.2.6_2 on FreeBSD. Additional code: Works: <?php // 2008-12-02 echo date('Y-m-d', strtotime('first Tuesday December 2008')); ?> Does not: <?php // 2008-12-08 echo date('Y-m-d', strtotime('first Monday December 2008')); ?> ------------------------------------------------------------------------ [2008-10-16 16:29:22] till@php.net Sorry to re-open, I found the same bug on: PHP Version 5.2.6-pl6-gentoo Some code to reproduce: <?php echo date('Y-m-d', strtotime('first Monday', mktime(0, 0, 0, 12, 1, 2008))); ?> Shows 2008-12-08, while indeed the first Monday in December is 2008-12-01. ------------------------------------------------------------------------ [2008-07-23 18:50:15] derick@php.net This bug has been fixed in CVS. Snapshots of the sources are packaged every three hours; this change will be in the next snapshot. You can grab the snapshot at http://snaps.php.net/. Thank you for the report, and for helping us make PHP better. ------------------------------------------------------------------------ [2008-07-17 10:32:00] derick@php.net Yeah, and I've done some work on that -- but it's not ready yet. ------------------------------------------------------------------------ [2008-07-17 10:29:15] m dot ford at leedsmet dot ac dot uk Then there's a doc problem, because currently http://php.net/strtotime describes its first argument as "The string to parse, according to the GNU » Date Input Formats syntax", with a link to the GNU documentation. If strtotime() does not, in fact, implement the entirety of what's described there, exactly as described, then what's actually implemented should be incorporated into the PHP manual and that link removed. ------------------------------------------------------------------------ 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 http://bugs.php.net/43452 -- Edit this bug report at http://bugs.php.net/?id=43452&edit=1

« previous php.bugs (#129777) next »