Solved

PHP list past months ??

Posted on 2007-03-23
4
505 Views
Last Modified: 2008-03-25
I'm trying to put together a quick blog together and want to display a list of months, say, around 20 with years past beginning from current year ie...

March 2007
Feb 2007
Jan 2007
Dec 2006     etc....

Can someone show me a function that'll do this? If the listing could have links such as the following....

March 2007  - index.php?m=3&y=2007

Thanks!!
0
Comment
Question by:kornflake
4 Comments
 
LVL 5

Accepted Solution

by:
Oscurochu earned 25 total points
ID: 18780110
check this out, im pretty sure it will help you

http://www.php.net/manual/en/ref.calendar.php
0
 
LVL 3

Assisted Solution

by:ERNesbitt
ERNesbitt earned 25 total points
ID: 18781919
I use: mktime( Hour, Min, Sec, Month, Day, Year ) to store my time stamps, that way I can inject variables for months and years.

$dtmBegin=mktime(0,0,0,$strBegMonth,1,$strBegYear);
$dtmEnd=mktime(0,0,0,$strEndMonth+1,0,$strEndYear);
/* The zero day for the next month is the last day of the previous month. e.g. mktime(0,0,0,3,0,2000); would give you the date stamp for Feb 29,2000 */

Then to search for dates I just search for everything between my start and end dates.  You can probably create a nested loop from there to loop through the years and then loop the months inside of that.
0
 
LVL 1

Expert Comment

by:Computer101
ID: 21207276
Forced accept.

Computer101
EE Admin
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
This article discusses how to create an extensible mechanism for linked drop downs.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to dynamically set the form action using jQuery.

773 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question