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
https://forums.phpfreaks.com/topic/238301-getting-3-months/
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
https://forums.phpfreaks.com/topic/238301-getting-3-months/#findComment-1224652
Share on other sites

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.