A List of Months

3 posts by 2 authors in: Forums > CMS Builder
Last Post: March 16, 2015   (RSS)

By gkornbluth - March 16, 2015

Here's some code that I've used to create a list of months that might help

<select name="month">  
  <?php foreach(range(1,12) as $month): ?>  
  <option value="<?php echo $month;?> <?php selectedIf($month,@$_REQUEST['month']);?>"><?php echo date("F",strtotime("1985-$month-01 00:00:00"));?></option>  
  <?php endforeach ?>  

There's also an interesting discussion at http://stackoverflow.com/questions/22735071/display-a-list-of-past-11-months-from-current-date

Jerry Kornbluth

The first CMS Builder reference book is now available on-line!

Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php

By Perchpole - March 16, 2015

Thanks, Jerry!