Solved

PHP list past months ??

Posted on 2007-03-23
4
502 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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Deprecated and Headed for the Dustbin By now, you have probably heard that some PHP features, while convenient, can also cause PHP security problems.  This article discusses one of those, called register_globals.  It is a thing you do not want.  …
These days socially coordinated efforts have turned into a critical requirement for enterprises.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

708 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now