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
Need help with simple code, back and forward buttons.
Basically, I have a set of pages in a folder, which have the title somephrasehere_09.php, somephrase
Gantt Chart Tool
Does anyone know of a good free gantt chart creator tool
Thanks
help connecting a form to php and then emailing the form
Ok. So, I made a form, and I need help to where when submitted, I get an email with the submitted de
check if value exists
I have googled this for a while and I am getting lots of different results. Is there a standard meth
CHECH A STRING FOR ' " ' (DOUBLE QUOTES)
I am checking for delimiter (.!?) and if there is a " after a sentence then it should neglect a
How to ask a regex question?
Hi, I thought I'd share some of my insight after seeing too many bad questions that either get ignor
Giving the below syntax error
Dear Experts,
I have used 2 buttons in gui status as display and cjhange.When the user wi
square instead of number
Hello
I do not know why but this code seems to work fine only in my xampp local insallation but n
Update Database
Hi All,
I have a problem with this:
Code: [Select]<?php
session_start();
How to make a mail Form secure?
I want to create an email Form on my web site. How can I make the Form secure so the submitted info