<?php
//New DateTime object representing current date.
$currentDate = new DateTime();
//Use the subtract function to subtract a DateInterval
$yesterdayTime = $currentDate->sub(new DateInterval('P1D'));
//Get yesterday date
$yesterday = $yesterdayTime->format('Y-m-d');
//Print yesterday date.
echo $yesterday;
?>