I am trying to use PHP’s Date Function to get the date of 7 days earlier in YYYY-MM-DD format.
when i try
i get an error
strtotime method provided by PHP.
date('Y-m-d', strtotime('-7 days'))
Thanks to @lonesomeday for pointing out my mistake in the comments 😉
With this, as with all PHP date stuff, it’s nicer to use the
$date = new DateTime('7 days ago'); echo $date->format('Y-m-d');