How do I add a certain number of days to the current date in PHP?
I already got the current date with:
$today = date(\'y:m:d\');
Ju
You can also use Object Oriented Programming (OOP) instead of procedural programming:
$fiveDays = new DateInterval('P5D');
$today = new DateTime();
$fiveDaysAgo = $today->sub(fiveDays); // or ->add(fiveDays); to add 5 days
Or with just one line of code:
$fiveDaysAgo = (new DateTime())->sub(new DateInterval('P5D'));