Jump to content

Listing last few months


matfish

Recommended Posts

Hi,

All im trying to do is list the last 4 months like:-

June
May
April
March

Firstly my code done the first two correctly but then would continue the 2nd month down the rest of the page. My current attempt worked yesterday (still being in May) but then looking today (1st June) its messed up again, its missing May.

Iv got:


[code]// this prints the curent month
echo "<p><a href='/resources/blog_archive_view.php?arch=".date("Ym")."'>".date("F")."</a></p>";


// this should print the last 3 months
for ($m = 3; $m > 0; $m--)
{

$last4month = mktime(0, 0, 0, date("m", $last)+$m, date("d", $last),  date("Y", $last));
                
echo date("F y",$last4month);
                
}[/code]

Ideally would like to get rid of the first echo and just have it loop the last 4 months, including this (current) month.

Any ideas/point me in the right direction to a script etc.. would be appreciated!

Thanks for you time.


Link to comment
https://forums.phpfreaks.com/topic/10935-listing-last-few-months/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

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.