Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

PHP list past months ??

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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
The viewer will learn how to dynamically set the form action using jQuery.
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.

790 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