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
How can I get my program to read a larger array ??
Hi:
I have this program that reads from an array to do calculations. The array are just t
Session login issue
I'm wondering how to fix a problem I'm having with a session-based login system
Say I go to h
How to assign a textbox value to PHP variable??
Hi ! Can any one help me out as quickly as possible. As I m new to PHP.
Plz tell me how to assign
Mysql error message
help me find out what this error message means:
"Duplicate entry '0' for key 'PRIMARY'&q
am I using this for loop correctly
Dear buddies!
Right now I am generating a report with some details for all the dealers.
PHP code needed to get/post form fields and request mysql query results.
I'm new to PHP
I've created an html form to allow the user to request a basic telephone dire
Move array index to end
Hey guys,
Quick question:
I have an array that looks like this:
Code: [Select]$var =
Php - mysql select?
hi, i have this code:
Code: <?php
session_start();
// dBase file
include &quo
PHP Upload issue
Hi guys,
I have stumble across an interesting issue with my script and is doing my head in.
Curl & sessions PLS HELP
Hello,
I have a problem with curl and sessions and i will try to explain the best i could.