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

New to mysqli library - Multiple query problem
Greetings,

I am writing a batch program that executes 3 queries on a single page. Using mysql

onClick='location.href=index.htm'> not working
Below is my code:

echo "<input type='button' value='redirect' onClick='location.h

SAP Logon Failed
I tried to login to SAP through MMC.

When i click start and give password.

it

values in array being escaped
I would like to submit some values - back to the same form for checking before processing...

header redirect problems? please help
Ok i am making a site that generates youtube thumbnails and i am generating an image that displays 1

Connecion issue
Hi,

For some reason, I keep getting this error when trying to connect:

Warning: mysql_

Delete HTML file after loading
I have limited experience with php and its been a year or two since I've last used it. I have a sma

how to read and write into a word document using php...?
hi,
I need,reading and writting into a word document using php.




Thank u inadva

session checking in page load
hai all I have a web site is www.Mryas.com in this my login page is Page1.aspx its co

Pagination won't carry results past page 2.
Hi all,

I've worked out my pagination script and its paginating fine until I click next from

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