cadams7407 Posted January 31, 2007 Share Posted January 31, 2007 hello world ... haha anyways. I have a for loop that I use to generate a list of months. Its worked very well .. until today (2007-01-31) heres code: echo "<TABLE BORDER=0 CELLPADDING=3 style=\"BORDER-COLLAPSE: collapse\"><tr><td align=right bgcolor='#F4ECA5'><B>"; //This generates the months Jan - Dec and lists them down the left of the table for($m = 01;$m <= 12; $m++){ $month = date("F", mktime(0, 0, 0, $m)); echo "<option value='$m'>".$month."<br /></option>"; } echo "</B></td><td>"; Normally I get a nice list like: January February March etc. But today the list is: January March March May May July July August October October December December ??? Wether or not this changes tomorrow (2007-02-01) will give me a clear indication if this is a php bug, or if my code is too sloppy. In the mean time, any advice out there? Thank you in advance. Almost forgot: php 4.3.11 | MySQL 4.1.11 | phpMyAdmin 2.6.4 | Apache 2.0.58 | Zend Opt. 2.6.2 Quote Link to comment Share on other sites More sharing options...
Jessica Posted January 31, 2007 Share Posted January 31, 2007 That is pretty funky...Uhm, can you try changing the 01 to just 1? Whenever I need to do this, I just use a simple array $months[1] = 'January'; etc, and just do foreach on it. It sounds faster than making timestamps and using date. Perhaps try that? Quote Link to comment Share on other sites More sharing options...
effigy Posted January 31, 2007 Share Posted January 31, 2007 Per the manual for mktime: Arguments may be left out in order from right to left; any arguments thus omitted will be set to the current value according to the local date and time. You did not give mktime a day or year, so it is using 31 / 2007. There is no February 31st, April 31st, June 31st, September 31st, or Novermber 31st this year, so they are spilling over into the next month. Use a day that every month has: mktime(0, 0, 0, $m, 1) Quote Link to comment Share on other sites More sharing options...
cadams7407 Posted February 1, 2007 Author Share Posted February 1, 2007 Per the manual for mktime: Arguments may be left out in order from right to left; any arguments thus omitted will be set to the current value according to the local date and time. You did not give mktime a day or year, so it is using 31 / 2007. There is no February 31st, April 31st, June 31st, September 31st, or Novermber 31st this year, so they are spilling over into the next month. Use a day that every month has: mktime(0, 0, 0, $m, 1) right on, makes sense. its working fine today .. but todays the 1st .. so ... yeah, what you said. Thanks! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.