Slowie Posted June 3, 2011 Share Posted June 3, 2011 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 Quote Link to comment Share on other sites More sharing options...
WebStyles Posted June 3, 2011 Share Posted June 3, 2011 the date functions is quite smart, you can use stuff like: $date = date('Y-m-d',strtotime('- 1 month')); hope this helps Quote Link to comment Share on other sites More sharing options...
Slowie Posted June 3, 2011 Author Share Posted June 3, 2011 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 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.