- Instant help with your Php coding problems

Get yesterday's date in PHP

Question:
How to get yesterday's date in PHP?
Answer:
$yesterday = new DateTime('yesterday');
echo $yesterday->format('Y-m-d');
Description:

To get yesterday's date in PHP simply use the DateTime class and instantiate it with the constructor parameter 'yesterday' Then you can format the DateTime object with the format method.

Share "How to get yesterday's date in PHP?"