ID:               40003
 User updated by:  matt at iws dot co dot nz
 Reported By:      matt at iws dot co dot nz
 Status:           Bogus
 Bug Type:         Date/time related
 Operating System: Linux 2.4
 PHP Version:      5.2.0
 New Comment:

Shouldn't "Second Monday Jan 2007" and "Second Tuesday Jan 2007" return
days consecutive days in Jan 2007, instead of dates one week apart? 

"Second Monday Feb 2007" and "Second Tuesday Feb 2007" return the
correct results. As far as I can tell the results are always
inconsistent for the weekday that is the first day of the month.

Example Code:
-------------
echo date('Y-m-d', strtotime('second monday jan 2007')); // returns
2007-01-15
echo date('Y-m-d', strtotime('second tuesday jan 2007')); // returns
2007-01-09


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

[2007-01-03 08:08:41] [EMAIL PROTECTED]

This is not a bug, but expected behaviour. To get the behaviour that
you want, simply use "Monday Jan 2007" (without the first).

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

[2007-01-02 23:15:33] matt at iws dot co dot nz

Description:
------------
Asking strtotime() for the date of the first occurrence of a particular
day of the week, when that day of the week is also the first day of the
month, returns the incorrect day. See examples below.




Reproduce code:
---------------
echo date('Y-m-d', strtotime('first monday jan 2007'));

echo date('Y-m-d', strtotime('first monday feb 2007'));  

echo date('Y-m-d', strtotime('first thursday feb 2007'));

echo date('Y-m-d', strtotime('first thursday jan 2007')); 

Expected result:
----------------
// First Monday Jan 2007
2007-01-01

// First Monday Feb 2007
2007-02-05

// First Thursday Feb 2007
2007-02-01

// First Thursday Jan 2007
2007-01-04

Actual result:
--------------
// First Monday Jan 2007 - incorrect
2007-01-08

// First Monday Feb 2007 - correct
2007-02-05

// First Thursday Feb 2007 - incorrect
2007-02-08

// First Thursday Jan 2007 - correct
2007-01-04


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


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

Reply via email to