PHP subtract 1 month from date formatted with date ('m-Y')

Grant picture Grant · Aug 3, 2016 · Viewed 69.3k times · Source

I'm trying to subtract 1 month from a date.

$today = date('m-Y');

This gives: 08-2016

How can I subtract a month to get 07-2016?

Answer

Mamta picture Mamta · Aug 3, 2016
 <?php 
  echo $newdate = date("m-Y", strtotime("-1 months"));

output

07-2016