|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2006-03-15 18:24 UTC] admin at yawnster dot com
Description:
------------
The gmdate() function produces March twice and misses out October under certain conditions.
Reproduce code:
---------------
<div id="month">
<select name="month">
<?php
for($i = 1; $i <=12; $i++)
{
$date = gmdate('F', mktime(0, 0, 0, $i, 1, 2006));
echo("<option value='$i'>$date</option>");
}
?>
</select>
</div>
Expected result:
----------------
Well it should produce a list of the Months in order into a drop-box.
Actual result:
--------------
Well it gives out the 12 months, but goes through March Twice, but misses out October.. This problem however doesnt occur within the date() function, so for the time being I'll use this..
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Oct 31 23:00:01 2025 UTC |
Works fine, which timezone does the following print: <?php echo date("e"), "\n"; ?>No bug here, you're mixing a function that works on local time (mktime) with one that works on gmt times (gmdate). If you mix that you get time skews. See the following correct script: <?php date_default_timezone_set("Europe/London"); for($i = 1; $i <=12; $i++) { $date1 = gmdate('F '.DATE_ISO8601, gmmktime(0, 0, 0, $i, 1, 2006)); echo "with mktime: $date1\n"; } ?>