Array of months from today
4 posts by 2 authors in: Forums > CMS Builder
Last Post: March 19, 2013 (RSS)
By Toledoh - March 19, 2013
Hi Guys,
How would I create:
<select>
<option value="March" selected>March</option>
<option value="April">April</option>
<option value="May">May</option>
<option value="June">June</option>
<option value="July">Jul</option>
</select>
I want the current month to be "selected" then the next 6 months listed.
Tim (toledoh.com.au)
By dwellingproductions - March 19, 2013 - edited: March 19, 2013
Hey Tim!
Others are much more competent than myself with PHP. However, I would probably approach this the following way:
<?php echo date('F'); // first month ?><br />
<?php echo date('F', strtotime('+1 month')); // next month ?><br />
<?php echo date('F', strtotime('+2 month')); // second next month ?><br />
<?php echo date('F', strtotime('+3 month')); // third next month ?><br />
<?php echo date('F', strtotime('+4 month')); // fourth next month ?><br />
So, for your specific purpose, I believe the code would be:
<select>
<option value="<?php echo date('F'); ?>" selected><?php echo date('F'); ?></option>
<option value="<?php echo date('F', strtotime('+1 month')); ?>"><?php echo date('F', strtotime('+1 month')); ?></option>
<option value="<?php echo date('F', strtotime('+2 month')); ?>"><?php echo date('F', strtotime('+2 month')); ?></option>
<option value="<?php echo date('F', strtotime('+3 month')); ?>"><?php echo date('F', strtotime('+3 month')); ?></option>
<option value="<?php echo date('F', strtotime('+4 month')); ?>"><?php echo date('F', strtotime('+4 month')); ?></option>
</select>
Hope that helps! :-)
- Jeremy
Dwelling Productions
www.dwellingproductions.com
By dwellingproductions - March 19, 2013 - edited: March 19, 2013
You bet! :-)
- Jeremy
Dwelling Productions
www.dwellingproductions.com