|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2008-07-31 00:47 UTC] 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
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Tue Dec 16 22:00:01 2025 UTC |
// 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";