#45661 [Opn->Bgs]: Error in mktime when omitting day
| From: | derick@php.net | Date: | Thu, 31 Jul 2008 07:16:09 +0000 |
| Subject: | #45661 [Opn->Bgs]: Error in mktime when omitting day | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-127429@lists.php.net to get a copy of this message | ||
ID: 45661
Updated by: derick@php.net
Reported By: frozenfire at thefrozenfire dot com
-Status: Open
+Status: Bogus
Bug Type: Date/time related
Operating System: Windows XP SP2
PHP Version: 5.2.6
New Comment:
Please do not submit the same bug more than once. An existing
bug report already describes this very problem. Even if you feel
that your issue is somewhat different, the resolution is likely
to be the same.
Thank you for your interest in PHP.
http://bugs.php.net/bug.php?id=11212
http://bugs.php.net/bug.php?id=44073
http://bugs.php.net/bug.php?id=44577
http://bugs.php.net/bug.php?id=43169
http://bugs.php.net/bug.php?id=41386
http://bugs.php.net/bug.php?id=38279
Previous Comments:
------------------------------------------------------------------------
[2008-07-31 01:21:55] frozenfire at thefrozenfire dot com
// 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";
------------------------------------------------------------------------
[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