How to Add Days to Date in PHP?

By Hardik Savani November 5, 2023 Category : PHP

This article goes into detail on how to add days to date in PHP. step by step explain how to add days to the current date in PHP. it's a simple example of how to add 7 days to date in PHP. This article goes into detail on how to add 30 days to date in PHP. Alright, let’s dive into the steps.

I will give you very simple example how to add days to date in PHP. so let's see both example with output:

Example 1: PHP Add Days to Date

index.php

<?php

$date = "2021-11-01";

$newDate = date('Y-m-d', strtotime($date. ' + 3 days'));

echo $newDate;

?>

Output:

2021-11-04

Example 2: PHP Add Days to Current Date

index.php

<?php

$newDate = date('Y-m-d', strtotime(' + 3 days'));

echo $newDate;

?>

Output:

2021-11-06

i hope it can help you...

Tags :
Shares