Jump to content
xisto Community
Sign in to follow this  
demolaynyc

Help On Date()

Recommended Posts

//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 by bluefish (see edit history)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.