Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.