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 Link to comment https://forums.phpfreaks.com/topic/238301-getting-3-months/ 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 Link to comment https://forums.phpfreaks.com/topic/238301-getting-3-months/#findComment-1224586 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 Link to comment https://forums.phpfreaks.com/topic/238301-getting-3-months/#findComment-1224652 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.