Sort Alternative/bi-monthly
Posted on
16th Feb 2014 07:03 pm by
admin
Hi all,
Am going mad trying to get something to work.
Did you know?Explore Trending and Topic pages for more stories like this.
I'm creating a CMS for a magazine. The magazine is published every 2 months and therefore the edition is nov-dec or jan-feb etc.
I've an archive option on the site and rather than listing:
dec
nov
oct
sept etc
I'd like to follow the magazine editions:
nov-dec
sept-oct
The code I have so far is:
echo '<p>Sort By:</p>';
$year = date("Y"); //get the current year
$startDate = "1 january".$year; // set the end date to current year
function printMonths($var)
{
$start = strtotime($var); //timestamp of the entered date
$now = strtotime("Now"); //timestamp of now so it does not write anything in the future
while ($now > $start) //while the start is less than now
{
echo '<a href="news_archive.php?s=&id=' . get_id() . '&month=' . date("F", $now) .'">'.date("F", $now).'</a>';
echo " | ";
$now = strtotime("-1 month", $now); // subtract a month from the start timestamp
}
}
printMonths($startDate); //execute the function
this works well listing the months from the current month back. But this is not what I need. If I alter the line
$now = strtotime("-1 month", $now);
to
$now = strtotime("-2 month", $now);
It starts in Nov and goes back to sept which is not right. It also doesn't show nov-dec etc.
Any help on this is much appreciated
No comments posted yet
Your Answer:
Login to answer
92
16
Other forums
Dealing with code in db query
I am dealing with C code and I need to make sure it is encoded some how to ensure its integrity and
Any Good MMORPGs you've played?
I'm about to have ALOT of free time on my hands (finished highschool) and I need something to fill t
Help with Password Encoding/Decoding?
Trying to design a "change password" tool. On my signup code I'm using base64_encode, now
Navigation include for all site directories
Hi,
I need a navigation include that can deal with directories at different levels on a site.
Price in PR
Dear Experts,
Why we have to enter the price in the PR, and why there is no free goods indicato
urldecode question
How would I format this line of code properly?
<?php echo urldecode($_GET['Title']); ?
trim function issues
Hi guys, total noob here...
So I've been tinkering around with a html and am using php to em
Help with PHP Email Script
Hi guys,
I'm a newbie to php and need help with the script below:
At the moment when I
header redirect problems? please help
Ok i am making a site that generates youtube thumbnails and i am generating an image that displays 1
weeks in a year
hi,
i found this snippet on php.net
QuoteFor the week number for weeks starting on Sunday: