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.
Did you know?Explore Trending and Topic pages for more stories like this.
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
Can't get the unicode character
I'm trying to get some text from various parts of a file. I have converted the file to hex (bin2hex)
how to put the 0-100 numbers into 1.txt and 100-200 into 2.txt ?
how to put the 0-100 numbers into 1.txt and 100-200 into 2.txt and so on 200-300 into file 3.txt ?
help need on ob_start()
Hi
I am a newbie in php, I have a code
Line number On/Off | Expand/Contract <?phpo
Php - mysql store data and use it later?
Hi, i' making a login page at the moment, however my username + password is stored many different pl
puting for loop in 1 value
hi ,
how do i put this code in 1 value:
Code: <?php
for ($i=1; $i<=5; $i
WELCOME SCREEN
first of all let me tell you what does my script do,
it´s a very simple query to show a e
Help with search.php
Hello All
I need the search engine on a site I am building at the moment to display the searc
SQL Injection
In my attempts to protect my database from mySQL injection I have created another problem for myself
PHP loop
Okay so I have several "articles" stored in a mysql database and am attempting to echo tho
Transport data between itab and textfield on ALV event
Hallo,
I have a ALV Grid ( cl_gui_alv_grid ) and I also have hotspot click event with a h