strtotime() understand 'last month' .
$last_month = date('F', strtotime('last month'));
You can also use the \DateTime class:
$date_time = new \DateTime('last month'); $last_month = $date_time->format('F');
It depends on what you need. If you want only the name of the previous month, then the first example will be wonderful. If you want to play with dates (for example, a cycle for months in a year), the \DateTime class makes this very simple.
source share