Re: odd while behavior...

From: Date: Sat, 16 Oct 2010 15:18:21 +0000
Subject: Re: odd while behavior...
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-308747@lists.php.net to get a copy of this message
This is because of your mktime() call. You're trying to get the zeroth day of the month, which is the last day of the preceding month. Using mktime(0, 0, 0, $i, 1) instead should give you the desired results, assuming you do start at 1, and not 0 as you have in your code. --- Simon Welsh On 17/10/2010, at 4:12, Jason Pruim <lists@pruimphotography.com> wrote: > Okay so I'm just playing around with some stuff trying to learn more and expand my > knowledge and I ran into something I don't understand... Take the following code: > > <?PHP > > echo "<select>"; > $i ="0"; > while($i <="12") { > > $dateformat = date("M", mktime(0,0,0, $i,0,0)); > $month = mktime(0,0,0, $i,0,0); > //echo date("M", mktime(0,0,0, $i,0,0)); > //echo "<br>inside while<br>"; > echo <<<HTML > <option value="{$i}">{$dateformat} {$i}</option> > HTML; > $i++; > } > echo "</select>"; > > ?> > > which does display a select drop down box with the month's in it... But on my test server > it starts the display at december... With setting $i = "1" i would have thought it should > start at january? > > Any ideas on what I missed? :) > > > Thanks for looking! :) > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php >

« previous php.general (#308747) next »