RE: [PHP] Trouble creating a list on months

From: Date: Wed, 01 Aug 2001 13:41:43 +0000
Subject: RE: [PHP] Trouble creating a list on months
Groups: php.general 
Request: Send a blank email to php-general+get-60647@lists.php.net to get a copy of this message
> -----Original Message----- > From: Mario A. Salinas [mailto:masPHP@amazon-networks.com] > Sent: Tuesday, July 31, 2001 7:33 PM > To: php-general@lists.php.net > Subject: [PHP] Trouble creating a list on months > > > The actual function is as follows: > ---------------------------------------------------- > function month_select($default=1) { > > $offset = date("n")-1; // value used to be 'm' > > echo ("<select name=month > style=\"font-family:Verdana,Helvetica;font-size:8pt;\">"); > for($x=1;$x<=12;$x++) { > $month = $x + $offset; > if($month>12) $month -= 12; > echo("<option value=$month"); > if($month==$default) echo(" selected"); > > echo(">".date("F",mktime(0,0,0,$month))."</option>"); Try changing this to echo ">".date("F",mktime(0,0,0,$month,1))."</option>"); > } > echo ("</select>"); > } > ---------------------------------------------------- > > Any Ideas what could be causing the problem? I'm new to this > and have been staring at it for a while. Your help is greatly > appreciated. Actually, I'd expect that if you try your code again today, it works just like you'd expect. Mktime() uses the current (local date/time) value for any parameters that you leave out. Since you were running this on July 31st, that means your mktime call was trying to build timestamps for February 31st (which is actually in March), April 31st (actually in May), and so on. --- Mark Roedel (roedelm@letu.edu) || "There cannot be a crisis next week. Systems Programmer / WebMaster || My schedule is already full." LeTourneau University || -- Henry Kissinger

« previous php.general (#60647) next »