demolaynyc 0 Report post Posted January 3, 2007 Hi, can someone post a source code that will display the last six months. ie: This month is January - display December, November, October, September, August, JulyI really need this urgently. Thx. Share this post Link to post Share on other sites
bluefish1405241537 0 Report post Posted January 3, 2007 (edited) //Set $m to value of current month, starting index at 0$m = date("m")-1;//Create array of month names$months = array(0 => "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December");//Iterate through last six monthsfor($t=$m-1;$t<=$m-6;$t--) { //Print a comma if not first in list if($t!=$m-1) echo ", "; //Print the month name, using modulo to make sure it is a positive value echo $months[$t % 12];}That should work. Excuse me if my PHP is rusty. Edited January 3, 2007 by bluefish (see edit history) Share this post Link to post Share on other sites
demolaynyc 0 Report post Posted January 4, 2007 No matter. Thanks a lot! Share this post Link to post Share on other sites
bluefish1405241537 0 Report post Posted January 4, 2007 Er, sorry, just noticed, should be $t>=$m-6, not <=. Share this post Link to post Share on other sites