ivytony Posted March 13, 2008 Share Posted March 13, 2008 I am thinking of listing each month in the last 5 years. for example: Jan 2003 Feb 2003 Mar 2003 .... Jan 2008 Feb 2008 Mar2008 This list should be dynamic in terms of showing the current month. I've looked through the date manual on php.net but didn't find any hint on implementing this. Can someone pls help me out? thanks Link to comment https://forums.phpfreaks.com/topic/95892-how-to-generate-a-list-of-past-months/ Share on other sites More sharing options...
l0ve2hat3 Posted March 13, 2008 Share Posted March 13, 2008 <? $i=0; while($i < 6){ $m=0; while($m < 12){ echo date('F Y', mktime(0, 0, 0, 1+$m, 1, date('Y')-$i))."<br>\n"; $m++; } $i++; } ?> Link to comment https://forums.phpfreaks.com/topic/95892-how-to-generate-a-list-of-past-months/#findComment-490977 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.