Jump to content

[SOLVED] How do I bring back the previous number of month and year?


blurredvision

Recommended Posts

I'm needing to create links to bring back the previous month and year in just their numbers.  I think it has to be done using something like mktime(), but I'm not at all familiar with it.  I'd like the cleanest possible solution, so that's why I'm asking you guys for help.

 

Today is June 1st, 2009.  Or, 6-2009.  I'd like a quick variable that will bring me 5-2009 (ideally, the month number and year would be separate variables).  So in my perfect world, I'd end up with $prev_month = 5; and $year = 2009;.  If today were January 15th, 2009, I'd want to end up with $prev_month = 12; and $year = 2008;.

 

Pretty simple, but I don't have any idea how to do it.  Do I use mktime(), or can I do some kind of date('n') -1;?

 

I appreciate the help and learning!

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.