how to get date of yesterday using php?
If you define the timezone in your PHP app (as you should), which you can do this way:
date_default_timezone_set('Europe/Paris');
Then it's as simple as:
$yesterday = new DateTime('yesterday'); // will use our default timezone, Paris
echo $yesterday->format('Y-m-d'); // or whatever format you want
(You may want to define a constant or environment variable to store your default timezone.)
Yesterday Date in PHP:
echo date("Y-m-d", strtotime("yesterday"));
try this
$tz = new DateTimeZone('Your Time Zone');
$date = new DateTime($today,$tz);
$interval = new DateInterval('P1D');
$date->sub($interval);
echo $date->format('d.m.y');
?>
there you go
date('d.m.Y',strtotime("-1 days"));
this will work also if month change