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
16
Other forums
An odd assignment statement. Can someone explain this assignment to me?
What purpose is served by the bit of code between the two equal signs in the $installurl set? Is th
Preventing blank or already entered values
Im trying to learn how to place a read file line by line and prevent duplicate entries and also BLAN
Multiple arrays inside data
Hi,
Simple question. I have a column called "array" in my database, and inserted in
Problem with creating FI documents
Hi, Experts!
when i create Fi doc. with standart transaction, i ve been had such problem
how to hide input fields on selection screen using variant attribute
Hello all,
I want to know how to hide input fields on selection screen using variant attr
Required to login help
I'm trying to set up my site so users have to be logged into the forum to access the site.I've been
PHP FTP Can't upload Big FIles
Anyone had any success using FTP to upload a file say 90m?
im using ftp_put and it returns fa
SQL Injection
In my attempts to protect my database from mySQL injection I have created another problem for myself
Extracting URL pointer within XML tag
Hi.
I'm trying to extract text between two quotation marks in XML. For example, I want to ex
RTF fomatting to email content
Im trying to sen an email with content is picked up from a rtf-file (file_get_contents('*.rtf'). Mai