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!

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.