Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

PHP list past months ??

Posted on 2007-03-23
4
Medium Priority
?
526 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
[X]
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
4 Comments
 
LVL 5

Accepted Solution

by:
Oscurochu earned 100 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 100 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

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

Question has a verified solution.

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

This article discusses how to create an extensible mechanism for linked drop downs.
This article discusses how to implement server side field validation and display customized error messages to the client.
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.
Suggested Courses

618 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