how to get yesterday date in php

In this tutorial i will show you how to get yesterday date in PHP means subtract one day. so lets start in code so you are easily understand how to subtract one day. You may also like How to add one year in current date using php and How to Add Months to Date in PHP.

We need set format data in function date(): Function date() returns a string formatted according to the given format string using the given integer timestamp or the current time if no timestamp is given.

PHP Code

<?php
echo date('Y/m/d',strtotime("-1 days"));
?>

you can do this by

date("F j, Y", time() - 60 * 60 * 24);

or by

date("F j, Y", strtotime("yesterday"));

And if you like this tutorials please share it with your friends via Email or Social Media.

Leave a Reply

Your email address will not be published. Required fields are marked *