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?

twyntee_trey
  • 175
  • 1
  • 11
  • 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
  • 23,450
  • 12
  • 63
  • 93
3

Here you go

echo date('Y-m-d', strtotime("+3 days"));
Mojtaba
  • 6,012
  • 4
  • 26
  • 40
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,671
  • 2
  • 32
  • 47
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
  • 692
  • 4
  • 13
  • 26