4

I am saving dates like so: 2013-11-06 using date function

date("Y-m-d")

Would like to add three days to the date. Would I need to use strtotime() for this?

Kyle Hagler
  • 165
  • 1
  • 10
  • You need to use [google](https://www.google.com/search?q=php+add+days+to+date). – sectus Nov 07 '13 at 04:33
  • Almost every question posted by this person could qualify for being off topic with the reason of "must demonstrate a minimal understanding of the problem being solved." – gloomy.penguin Nov 07 '13 at 04:38

4 Answers4

10

Add days to a date (PHP)

$datetime = new DateTime('2013-01-22');
$datetime->modify('+1 day');
echo $datetime->format('Y-m-d H:i:s');

you may find here more Date time

Update

Community
  • 1
  • 1
Manwal
  • 22,994
  • 11
  • 59
  • 91
3

Here you go

echo date('Y-m-d', strtotime("+3 days"));
Mojtaba
  • 5,882
  • 4
  • 25
  • 39
1

Here, really easy:

$date=date("Y-m-d");
$date_plus_3_days=date("Y-m-d", strtotime("+3 days"));

strtotime can do lots of other related things: PHP.net documentation.

Robbie Wxyz
  • 7,326
  • 2
  • 29
  • 45
1

You can also use this.

$date = new DateTime(date("Y-m-d"));
$date->add(new DateInterval('P3D'));
echo $date->format('Y-m-d');
Rakesh K
  • 670
  • 3
  • 13
  • 26