Jump to content

getting 3 months


Slowie

Recommended Posts

Hi Guys hopefully this will be a quick one.

 

how would i go about getting the previous 3 months on the 1st

 

example

 

if its the 15/06/2011 i want the query to pull

 

01/05/2011

01/04/2011

01/03/2011

 

currently i have

 

$lastmonth =  date("m/d/Y", strtotime(date('m') -1 .'/01/'.date('Y').' 00:00:00'));

 

which pulls back the last month on the 1st but incrementing it to

 

$lastmonth =  date("m/d/Y", strtotime(date('m') -2 .'/01/'.date('Y').' 00:00:00'));

 

doesnt bring back the expected result

Link to comment
Share on other sites

Thank you so much it was alot easier than i thought it would be after reading your post i changed

 

$lastmonth =  date("m/d/Y", strtotime(date('m') -1 .'/01/'.date('Y').' 00:00:00'));

 

to

 

$lastmonth =  date("Y/m/d", strtotime(date('m') .'/01/'.date('Y').' 00:00:00'. '- 1 month'));

 

worked perfectly

 

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.