bruckerrlb Posted May 3, 2010 Share Posted May 3, 2010 I'm trying to create a loop, starting from today, until let's say 30 days down the road. The code I have now looks like <?php $today = date("D M d"); //$theday = date( for ($i=$today; $i<=30; $i++) { $date = $today++; ?> <option value="<?php echo $date; ?>"><?php echo $date;?></option> <?php echo $date; } ?> This just seems to be looping the number part (d) and not the M or the D, can someone show me how to do this or point me in the right direction? Thanks Quote Link to comment Share on other sites More sharing options...
JAY6390 Posted May 3, 2010 Share Posted May 3, 2010 $days = 0; $maxdays = 30; while($days < $maxdays) { echo date('D m d', time() + $days * 86400).'<br />'; $days++; } Quote Link to comment Share on other sites More sharing options...
litebearer Posted May 3, 2010 Share Posted May 3, 2010 Grrrr I typpe too slow $i=1; while ($i<31) { echo date('Y-m-d', strtotime("+$i days")) . "<br>"; $i++; } Quote Link to comment Share on other sites More sharing options...
JAY6390 Posted May 3, 2010 Share Posted May 3, 2010 $i=1; while ($i<31) { if($i==1) { echo date('Y-m-d', strtotime("+1 days")) . "<br>"; }else{ echo date('Y-m-d', strtotime("+$i days")) . "<br>"; } $i++; } I don't see the reason for having both echo lines in the above code, since essentially it will do the same with just $i=1; while ($i<31) { echo date('Y-m-d', strtotime("+$i days")) . "<br>"; $i++; } Quote Link to comment Share on other sites More sharing options...
bruckerrlb Posted May 3, 2010 Author Share Posted May 3, 2010 that's great, exactly what I was looking for, 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.