I know how to get the current date in PHP like so---
echo date("Y/m/d")
But I am not sure how to get it the previous day. I mean today is 2015-08-10, so how I can get yesterday's date 2015-08-09.
UNIX_TIMESTAMP(DATE_SUB(NOW(), INTERVAL 1 DAY)
Is it the solution, but do not know how it can solve my problem.
Does anyone know how to get the previous day in the PHP?
I have looked a lot but did not find any simple solution for this, anyone knows any solution for this problem. Thanks in advance.
Using strtotime() to Get Yesterday's Date in PHP strtotime() is a built-in PHP function parses an English textual DateTime into a Unix timestamp from January 1, 1970, 00:00:00 GMT.
$newDate = date('Y-m-d', strtotime('tomorrow')); echo $newDate; ?>
Use this-
date('Y/m/d',strtotime("-1 days"));
Or Use DateTime
class like this-
$date = new DateTime();
echo $date->modify("-1 days")->format('Y-m-d');
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With