ID:               45661
 User updated by:  frozenfire at thefrozenfire dot com
 Reported By:      frozenfire at thefrozenfire dot com
 Status:           Open
 Bug Type:         Date/time related
 Operating System: Windows XP SP2
 PHP Version:      5.2.6
 New Comment:

// Working code. Produces intuitive output.
// Original bug report used 0 as 5th param
for($i=1; $i<13; $i++) echo date('M', mktime(0, 0, 0, $i, 1))."\n";


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

[2008-07-31 00:47:56] frozenfire at thefrozenfire dot com

Description:
------------
There is a bug in mktime, where omission of the day parameter causes
some issues.

Most notably, when attempting to iterate through months. See the
reproduction code for a better explanation.

Reproduce code:
---------------
// Bugged code. Produces "Mar" twice.
for($i=1; $i<13; $i++) echo date('M', mktime(0, 0, 0, $i))."\n";

// Working code. Produces intuitive output.
for($i=1; $i<13; $i++) echo date('M', mktime(0, 0, 0, $i, 0))."\n";

Expected result:
----------------
Jan
Feb
Mar
Apr
Jun
Jul
Aug
Sep
Oct
Nov
Dec

Actual result:
--------------
Jan
Mar
Mar
Apr
Jun
Jul
Aug
Sep
Oct
Nov
Dec


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


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

Reply via email to