PHP Date Exercises : Get yesterday's date
PHP date: Exercise-13 with Solution
Write a PHP script to get yesterday's date.
<?php $dt = new DateTime(); $dt->sub(new DateInterval('P1D')); echo $dt->format('F j, Y')."\n"; ?>
July 10, 2017
N.B.: The result may varry for your system date and time.
PHP Code Editor:
Have another way to solve this solution? Contribute your code (and comments) through Disqus.
What is the difficulty level of this exercise?