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.

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 Like 16 Dislike
Previous forums Next forums
Other forums

Displaying returned XML in another PHP page
I have an online payment form that will return XML given if a payment is successful or declines. I

sql problems
I am having a small problem with my sql statement. it is inserting into 4 of the fields.

fie

convert static html data into dynamic
hi all

i need to convert a website which has static above 2000 articles into dynamic and add

Auto fill in input value based on User_ID
Hello,

I'm looking form some input on the following problem.

User loads page ->

delete comma
HI,

How to delete "," at the end of the string.
Code: $match = 2009/02/03/a2corr

Searching keywords from array
Hello everyone, Im just wondering if someone could help me with another issue im having. Im still le

writing a screen scraper
Hello,

I'm writing a screen scraper application and want to be able to get absolute addresses

Find current logon time
Hi,
in my sql script i want to query and find out the logon time of the current session.
<

Comma seperated implode & modifying returned string.
I have a PHP post form that posts up to 4 variables. I need whatever variables are passed to be comb

Linkage between two scripts
Okay say I have this for a link in a script:

Code: <li><a href="#&q

Sign up to write
Sign up now if you have flare of writing..
Login   |   Register
Follow Us
Indyaspeak @ Facebook Indyaspeak @ Twitter Indyaspeak @ Pinterest RSS



Play Free Quiz and Win Cash