Get previous month date range

three3 picture three3 · Jan 1, 2012 · Viewed 9.4k times · Source

I need help getting the previous months full date range in the following format: Y-m-d

I have successfully been able to get "this" months full date range but not the "previous" months full date range.

Any help is greatly appreciated!

Answer

Tadeck picture Tadeck · Jan 1, 2012

This gets the job done correctly:

echo date('Y-m-01 - Y-m-t', strtotime('previous month'));

Here is the proof: http://ideone.com/L82ZW