Previous day and month date functions in PHP

If you are looking how to pull up the previous day or month from current date, it is very easy to do it in php. Look at the following pieces of code.

This code will do the necessary conversions from one format to another.

$old_date = "05-Dec-2015";
$new_date = date("Y-m-d", strtotime($old_date) );
$prev_date = date("Y-m-d", strtotime('-3 days', strtotime($new_date)) );
// output: 2015-12-02

This code will return start and end days of previous month

$first = date('Y-m-d', strtotime("first day of -1 month"));
$last = date('Y-m-d', strtotime("last day of -1 month"));